-
Notifications
You must be signed in to change notification settings - Fork 544
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Methods for create and call context specific tenanted keystores #6189
Methods for create and call context specific tenanted keystores #6189
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6189 +/- ##
============================================
- Coverage 41.03% 40.84% -0.19%
- Complexity 15398 15526 +128
============================================
Files 1796 1797 +1
Lines 122999 124792 +1793
Branches 21403 22002 +599
============================================
+ Hits 50475 50975 +500
- Misses 65034 66274 +1240
- Partials 7490 7543 +53
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
...rbon.identity.core/src/main/java/org/wso2/carbon/identity/core/IdentityKeyStoreResolver.java
Outdated
Show resolved
Hide resolved
...tity.core/src/main/java/org/wso2/carbon/identity/core/util/IdentityKeyStoreResolverUtil.java
Outdated
Show resolved
Hide resolved
...t/src/main/java/org/wso2/carbon/security/keystore/service/IdentityKeyStoreGeneratorImpl.java
Outdated
Show resolved
Hide resolved
* @param context the context for which the KeyStore is to be generated. | ||
* @throws KeyStoreManagementException if an error occurs during KeyStore creation or initialization. | ||
*/ | ||
public void generateContextKeyStore(String tenantDomain, String context) throws KeyStoreManagementException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we reuse an already available keystore generator from the kernel?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We dont have a keystore generation method in the kernel, it is currently in multitenancy repo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Multi tenancy has key store generation logic once this fix is merged, we can improve further so that multi tenancy will call this logic to create tenanted keystore
...t/src/main/java/org/wso2/carbon/security/keystore/service/IdentityKeyStoreGeneratorImpl.java
Outdated
Show resolved
Hide resolved
...t/src/main/java/org/wso2/carbon/security/keystore/service/IdentityKeyStoreGeneratorImpl.java
Outdated
Show resolved
Hide resolved
...t/src/main/java/org/wso2/carbon/security/keystore/service/IdentityKeyStoreGeneratorImpl.java
Outdated
Show resolved
Hide resolved
...t/src/main/java/org/wso2/carbon/security/keystore/service/IdentityKeyStoreGeneratorImpl.java
Show resolved
Hide resolved
...t/src/main/java/org/wso2/carbon/security/keystore/service/IdentityKeyStoreGeneratorImpl.java
Outdated
Show resolved
Hide resolved
...t/src/main/java/org/wso2/carbon/security/keystore/service/IdentityKeyStoreGeneratorImpl.java
Outdated
Show resolved
Hide resolved
...t/src/main/java/org/wso2/carbon/security/keystore/service/IdentityKeyStoreGeneratorImpl.java
Outdated
Show resolved
Hide resolved
...t/src/main/java/org/wso2/carbon/security/keystore/service/IdentityKeyStoreGeneratorImpl.java
Outdated
Show resolved
Hide resolved
...t/src/main/java/org/wso2/carbon/security/keystore/service/IdentityKeyStoreGeneratorImpl.java
Outdated
Show resolved
Hide resolved
...rbon.identity.core/src/main/java/org/wso2/carbon/identity/core/IdentityKeyStoreResolver.java
Show resolved
Hide resolved
...t/src/main/java/org/wso2/carbon/security/keystore/service/IdentityKeyStoreGeneratorImpl.java
Show resolved
Hide resolved
PR builder started |
526eb1f
to
e812eec
Compare
...rbon.identity.core/src/main/java/org/wso2/carbon/identity/core/IdentityKeyStoreResolver.java
Show resolved
Hide resolved
...t/src/main/java/org/wso2/carbon/security/keystore/service/IdentityKeyStoreGeneratorImpl.java
Show resolved
Hide resolved
...t/src/main/java/org/wso2/carbon/security/keystore/service/IdentityKeyStoreGeneratorImpl.java
Outdated
Show resolved
Hide resolved
PR builder completed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving the pull request based on the successful pr build https://github.com/wso2/product-is/actions/runs/12254955875
e812eec
to
6ca0b3d
Compare
...t/src/main/java/org/wso2/carbon/security/keystore/service/IdentityKeyStoreGeneratorImpl.java
Outdated
Show resolved
Hide resolved
PR builder started |
PR builder completed |
PR builder started |
PR builder completed |
The reason for above two failures are I am adding a jks file for unit tests and patch diff is failing.
|
PR builder started |
PR builder completed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving the pull request based on the successful pr build https://github.com/wso2/product-is/actions/runs/12282054757
Quality Gate passedIssues Measures |
* @param context the context | ||
* @return a concatenated string in the format tenantDomain:context | ||
*/ | ||
private String buildDomainWithContext(int tenantId, String context) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall we rename the method to avoid confusion with buildDomainWithContext(int tenantId, String context)
from IdentityKeyStoreResolverUtil?
import java.security.cert.X509Certificate; | ||
import java.util.Date; | ||
|
||
import static org.wso2.carbon.security.SecurityConstants.KeyStoreMgtConstants.KEY_STORE_CONTEXT_SEPARATOR; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can use
import static org.wso2.carbon.identity.core.util.IdentityKeyStoreResolverConstants.KEY_STORE_CONTEXT_SEPARATOR
instead
Proposed changes in this pull request
Public Issue: wso2/product-is#21985
The pull request titled "Create and Use Context KeyStore" introduces a method,
generateContextKeyStore
, designed to generate a context-specific KeyStore for a given tenant domain. This method ensures that each tenant has a unique KeyStore associated with a specific context, enhancing security and isolation between tenants.Key Features of the Implementation:
Tenant Identification: Retrieves the tenant ID using
IdentityTenantUtil.getTenantId(tenantDomain)
to uniquely identify the tenant.KeyStore Manager Initialization: Initializes the
KeyStoreManager
instance for the specific tenant, facilitating KeyStore operations.Registry Initialization: Calls
IdentityTenantUtil.initializeRegistry(tenantId)
to set up the tenant's registry space, preparing the environment for KeyStore operations.Existence Check: Before proceeding with creation, checks if a KeyStore already exists for the given context using
isContextKeyStoreExists(context)
. If it exists, the method exits early to prevent duplication.KeyStore Creation: If the KeyStore does not exist:
Exception Handling: Catches exceptions during the process, logs detailed error messages, and throws a
KeyStoreManagementException
to signal issues in KeyStore creation.Hi all,
I tested the following scenarios.
For Super Tenant and Tenant with an Existing Context Keystore:
For a Tenant with No Context Keystore:
Edge Cases:
Expired Cookies: Tested scenarios where a cookie generated by the super tenant exists without a valid session (since the cookie is set for six months, this scenario is possible). In this case, validation should fail gracefully without throwing an error. When the setCookie method is called after this, the MFA context keystore is created, and a new cookie is set.
-Subsequent Requests: Validated that subsequent requests pass the cookie validation successfully.
Todo:
Unit Test Coverage for Created Class