Skip to content

Commit 54a813d

Browse files
mo-automoabuduttarnabpujavscoderabbitai[bot]
authored
fix(jans-config-api): address security scan findings (#15616)
* fix(jans-config-api): address security scan findings Part of #15571. Co-authored-by: Mohammad Abudayyeh <47318409+moabu@users.noreply.github.com> Signed-off-by: moauto <54212639+mo-auto@users.noreply.github.com> * fix(jans-config-api): address CodeRabbit review - read enableLock and keep lock record past lockExpTime - policy-store: count issuer bytes, check iss, accept root issuer file, validate issuer data via central directory - mask multiline Cedar strings - keep total count for limit=0 user search - skip tknCde path param in audit log - ignore JSON Patch test ops when detecting clientSecret changes - allow metadata-only asset updates when upload is disabled - redact query and user-info from HTTP URI logs Co-authored-by: Mohammad Abudayyeh <47318409+moabu@users.noreply.github.com> Signed-off-by: moauto <54212639+mo-auto@users.noreply.github.com> * docs(jans-config-api): restore swagger spec Local build regenerated it from stale artifacts. Co-authored-by: Mohammad Abudayyeh <47318409+moabu@users.noreply.github.com> Signed-off-by: moauto <54212639+mo-auto@users.noreply.github.com> * fix(jans-config-api): cap lock time, budget zip CD - Memcached reads TTLs over 30 days as timestamps, so keep the 30-day lock record and cap lockExpTime at 29 days - count every central-directory entry against the archive budget Co-authored-by: Mohammad Abudayyeh <47318409+moabu@users.noreply.github.com> Signed-off-by: moauto <54212639+mo-auto@users.noreply.github.com> * feat: address code rabbit comments Signed-off-by: duttarnab <arnab.bdutta@gmail.com> * fix(jans-config-api): ignore policy comments in scope map - Strip Cedar comments before extracting role, resource and actions - Stop webhook batch on interrupt; log ExecutionException separately - Use ArrayList for sequentially built parent feature lists - Register AdminUIService and WebhookService tests in suite Co-authored-by: Mohammad Abudayyeh <47318409+moabu@users.noreply.github.com> Signed-off-by: moauto <54212639+mo-auto@users.noreply.github.com> * refactor(jans-config-api): simplify policy tokenizer Reuses stripComments in tokenizePolicy and drops loop-counter writes to clear Sonar S127/S3776 on the Cedar policy scanner. Co-authored-by: Mohammad Abudayyeh <47318409+moabu@users.noreply.github.com> Signed-off-by: moauto <54212639+mo-auto@users.noreply.github.com> * fix: address security scan findings Signed-off-by: duttarnab <arnab.bdutta@gmail.com> * fet: address code-rabbit comments Signed-off-by: duttarnab <arnab.bdutta@gmail.com> * test(jans-config-api): fix AdminUISecurityService tests - Expect 400 for validation failures thrown before persistence - Stub web-server host in invalid-archive test - Stub findEntries for delete not-found - Rebuild fixture as Cedarling v2 store (metadata.json, schema, policies) plus the Admin UI trusted-issuer file Co-authored-by: Mohammad Abudayyeh <47318409+moabu@users.noreply.github.com> Signed-off-by: moauto <54212639+mo-auto@users.noreply.github.com> * fix(jans-config-api): keep admin disable over auto-unlock Lock record stores the user's updatedAt after locking. Auto-unlock is refused when the entry changed since, so an administrator disable made during the lock is not reverted on expiry. Co-authored-by: Mohammad Abudayyeh <47318409+moabu@users.noreply.github.com> Signed-off-by: moauto <54212639+mo-auto@users.noreply.github.com> * feat(config-api): security scan changes for SMTP and Token endpoint Signed-off-by: pujavs <pujas.works@gmail.com> * fix(config-api): Correct token revocation, client secret handling, search validation, TLS pool settings and scopes; simplify archive validation <!-- coderabbit-ai-generated:v1 --> * fix(jans-config-api): revoke tokens before session delete A failed token revocation now leaves the session in place, so the revoke request can be retried instead of orphaning active tokens. Co-authored-by: Mohammad Abudayyeh <47318409+moabu@users.noreply.github.com> Signed-off-by: moauto <54212639+mo-auto@users.noreply.github.com> * fix(jans-config-api): address security scan findings Signed-off-by: pujavs <pujas.works@gmail.com> * fix: address code-rabbit comments Signed-off-by: duttarnab <arnab.bdutta@gmail.com> * fix(jans-config-api): address security scan findings Signed-off-by: pujavs <pujas.works@gmail.com> * fix(jans-config-api): address security scan findings Signed-off-by: pujavs <pujas.works@gmail.com> * fix(jans-config-api): address security scan findings Signed-off-by: pujavs <pujas.works@gmail.com> * refactor(jans-config-api): clear Sonar smells Co-authored-by: Mohammad Abudayyeh <47318409+moabu@users.noreply.github.com> Signed-off-by: moauto <54212639+mo-auto@users.noreply.github.com> * fix(jans-config-api): address security scan findings Signed-off-by: pujavs <pujas.works@gmail.com> * test(jans-config-api): enable info log in audit test Co-authored-by: Mohammad Abudayyeh <47318409+moabu@users.noreply.github.com> Signed-off-by: moauto <54212639+mo-auto@users.noreply.github.com> --------- Signed-off-by: moauto <54212639+mo-auto@users.noreply.github.com> Signed-off-by: duttarnab <arnab.bdutta@gmail.com> Signed-off-by: pujavs <pujas.works@gmail.com> Co-authored-by: Mohammad Abudayyeh <47318409+moabu@users.noreply.github.com> Co-authored-by: duttarnab <arnab.bdutta@gmail.com> Co-authored-by: pujavs <pujas.works@gmail.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent 3710ed5 commit 54a813d

68 files changed

Lines changed: 2721 additions & 749 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎jans-config-api/common/src/main/java/io/jans/configapi/model/configuration/ApiAppConfiguration.java‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ public class ApiAppConfiguration implements Configuration {
3939
@Schema(description = "Client IDs exempt from the User Role-Permission mapping check. Only honoured for tokens that carry no user, so a user token is always checked. Empty by default.")
4040
private List<String> userRolePermissionExcludedClients;
4141

42+
@Schema(description = "Flag to enable/disable introspection of JWT access tokens so revoked tokens are rejected before expiry. Default value `false`.")
43+
private boolean jwtIntrospectionEnabled;
44+
4245
@Schema(description = "Flag to enable/disable request audit. Default value `false`.")
4346
private boolean disableAuditLogger;
4447

@@ -198,6 +201,14 @@ public void setUserRolePermissionExcludedClients(List<String> userRolePermission
198201
this.userRolePermissionExcludedClients = userRolePermissionExcludedClients;
199202
}
200203

204+
public boolean isJwtIntrospectionEnabled() {
205+
return jwtIntrospectionEnabled;
206+
}
207+
208+
public void setJwtIntrospectionEnabled(boolean jwtIntrospectionEnabled) {
209+
this.jwtIntrospectionEnabled = jwtIntrospectionEnabled;
210+
}
211+
201212
public boolean isDisableAuditLogger() {
202213
return disableAuditLogger;
203214
}
@@ -465,7 +476,7 @@ public String toString() {
465476
+" ,validateUserInumInIntrospectionFlag=" + validateUserInumInIntrospectionFlag
466477
+" ,fetchUserRoleInIntrospectionFlag=" + fetchUserRoleInIntrospectionFlag
467478
+" ,userRolePermissionExcludedClients=" + userRolePermissionExcludedClients
468-
+ ", disableAuditLogger=" + disableAuditLogger + ", customAttributeValidationEnabled="
479+
+ ", jwtIntrospectionEnabled=" + jwtIntrospectionEnabled + ", disableAuditLogger=" + disableAuditLogger + ", customAttributeValidationEnabled="
469480
+ customAttributeValidationEnabled + ", acrValidationEnabled=" + acrValidationEnabled
470481
+ ", returnClientSecretInResponse=" + returnClientSecretInResponse
471482
+ ", returnEncryptedClientSecretInResponse=" + returnEncryptedClientSecretInResponse

‎jans-config-api/common/src/main/java/io/jans/configapi/util/ApiConstants.java‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,8 @@ private ApiConstants() {}
165165
public static final String PROTECTION_TYPE_OAUTH2 = "oauth2";
166166
public static final String PROTECTION_TYPE_UMA = "uma";
167167
public static final String ISSUER = "issuer";
168+
public static final String AUTHENTICATED_SUBJECT_ATTRIBUTE = "jans.configapi.authenticatedSubject";
169+
public static final String AUTHENTICATED_CLIENT_ATTRIBUTE = "jans.configapi.authenticatedClient";
168170

169171
// Connection pool properties
170172
public static final int CONNECTION_POOL_MAX_TOTAL = 200;

‎jans-config-api/docs/jans-config-api-swagger.yaml‎

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13954,7 +13954,6 @@ paths:
1395413954
security:
1395513955
- oauth2:
1395613956
- https://jans.io/oauth/jans-auth-server/session.delete
13957-
- revoke_session
1395813957
- oauth2:
1395913958
- https://jans.io/oauth/jans-auth-server/session.admin
1396013959
- oauth2:
@@ -13985,7 +13984,6 @@ paths:
1398513984
security:
1398613985
- oauth2:
1398713986
- https://jans.io/oauth/jans-auth-server/session.delete
13988-
- revoke_session
1398913987
- oauth2:
1399013988
- https://jans.io/oauth/jans-auth-server/session.admin
1399113989
- oauth2:
@@ -15695,19 +15693,19 @@ components:
1569515693
type: string
1569615694
selected:
1569715695
type: boolean
15698-
adminCanAccess:
15699-
type: boolean
15700-
userCanAccess:
15701-
type: boolean
1570215696
whitePagesCanView:
1570315697
type: boolean
1570415698
adminCanView:
1570515699
type: boolean
15706-
adminCanEdit:
15700+
userCanEdit:
1570715701
type: boolean
1570815702
userCanView:
1570915703
type: boolean
15710-
userCanEdit:
15704+
adminCanEdit:
15705+
type: boolean
15706+
userCanAccess:
15707+
type: boolean
15708+
adminCanAccess:
1571115709
type: boolean
1571215710
baseDn:
1571315711
type: string
@@ -16691,8 +16689,6 @@ components:
1669116689
spiffeBundleReadTimeoutMs:
1669216690
type: integer
1669316691
format: int32
16694-
fapi:
16695-
type: boolean
1669616692
allResponseTypesSupported:
1669716693
uniqueItems: true
1669816694
type: array
@@ -16702,6 +16698,8 @@ components:
1670216698
- code
1670316699
- token
1670416700
- id_token
16701+
fapi:
16702+
type: boolean
1670516703
AuthenticationFilter:
1670616704
required:
1670716705
- baseDn
@@ -17462,10 +17460,6 @@ components:
1746217460
type: boolean
1746317461
tlsClientAuthSubjectDn:
1746417462
type: string
17465-
accessTokenSigningKid:
17466-
type: string
17467-
idTokenSigningKid:
17468-
type: string
1746917463
runIntrospectionScriptBeforeJwtCreation:
1747017464
type: boolean
1747117465
keepClientAuthorizationAfterExpiration:
@@ -17699,6 +17693,10 @@ components:
1769917693
description: "Client IDs exempt from the User Role-Permission mapping\
1770017694
\ check. Only honoured for tokens that carry no user, so a user token\
1770117695
\ is always checked. Empty by default."
17696+
jwtIntrospectionEnabled:
17697+
type: boolean
17698+
description: Flag to enable/disable introspection of JWT access tokens so
17699+
revoked tokens are rejected before expiry. Default value `false`.
1770217700
disableAuditLogger:
1770317701
type: boolean
1770417702
description: Flag to enable/disable request audit. Default value `false`.

‎jans-config-api/plugins/admin-ui-plugin/agama/project/README.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,13 @@ Below is a typical configuration for the Agama-PW project:
7979
| ----------------- | -------- | ------------------------------------------------------------------------------------------------------------- | ------- |
8080
| `maxLoginAttempt` | Yes | Maximum number of consecutive failed login attempts allowed before the account is locked. | `6` |
8181
| `enableLock` | Yes | Enables or disables the account lockout feature after the maximum number of failed login attempts is reached. | `true` |
82-
| `lockExpTime` | Yes | Duration, in seconds, for which the account remains locked before it is automatically unlocked. | `180` |
82+
| `lockExpTime` | Yes | Duration, in seconds, for which the account remains locked before it is automatically unlocked. Maximum 2505600 (29 days). | `180` |
8383

8484
> **Note**
8585
>
8686
> If `enableLock` is set to `true`, users who exceed `maxLoginAttempt` consecutive failed login attempts will be locked out for the duration specified by `lockExpTime`. If `enableLock` is set to `false`, failed login attempts will not trigger account lockout regardless of the `maxLoginAttempt` value.
87+
>
88+
> Automatic unlock only applies to accounts locked by this flow, which keeps a lock record in the cache for 30 days. Accounts disabled by an administrator, locked before upgrading to this version, or whose lock record was lost (e.g. an in-memory cache restart) must be re-activated by an administrator.
8789
8890

8991
### Test The Flow

‎jans-config-api/plugins/admin-ui-plugin/agama/project/code/org.gluu.agama.pw.main.flow‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@ Repeat 6 times max
3030
When uiFeedback.succeed is true
3131
// add entry in log file for successfull login attempt.
3232
Log "@info Valid credentials provided"
33+
// Finish with the identity resolved during authentication, not the submitted login text.
34+
authenticatedUserId = Call validationService getAuthenticatedUserId
3335
// Password validation completed successfuly!
34-
Finish credentials.username
36+
Finish authenticatedUserId
3537
// Invalid credentials provided.
3638
Log "@error Invalid credentials provided"
3739
When conf.enableLock is true

‎jans-config-api/plugins/admin-ui-plugin/agama/project/code/org.gluu.agama.pw.reset.flow‎

Lines changed: 52 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -17,57 +17,60 @@ Repeat 3 times max
1717
Log "@info User found with e-mail % " mailForm.mail
1818
// OTP to verify user
1919
otp = Call resetService sendEmail mailForm.mail
20-
// OTP form feedback
21-
otpFormFeedback = {}
22-
// Max 3 times repeat
23-
Repeat 3 times max
24-
// OTP Form
25-
otpFormData = RRF "otp.ftlh" otpFormFeedback
26-
// If OTP match
27-
When otpFormData.passcode is otp
28-
// OTP matches
29-
Log "@info OTP matches"
30-
// Assign variable Re-set Password Form Feedback
31-
resetPassFormFeedback = {}
32-
// Max 3 times repeat
33-
Repeat 3 times max
34-
// Re-set Password Form
35-
passFormData = RRF "passwordForm.ftlh" resetPassFormFeedback
36-
// Check password policy
37-
isPassPolicyMatch = Call resetService passwordPolicyMatch passFormData.password
38-
// Password policy Match
39-
When isPassPolicyMatch is true
40-
// Password policy match
41-
Log "@info Password policy match"
42-
// if password match
43-
When passFormData.password is passFormData.confirmPassword
44-
// Password and confirmPassword match
45-
Log "@info Password and confirmPassword match"
46-
// Update user password
47-
inum | E = Call resetService updateUserPassword passFormData.password mailForm.mail
48-
// If password update successfully
49-
When inum is not null
50-
// Password update successfully
51-
Log "@info Password update successfully"
52-
// acknowledgement
53-
acknowledgement = RRF "acknowledgement.ftlh"
54-
// Flow finished successfully
55-
Finish user.uid
56-
Otherwise
57-
// Password not updated
58-
Log "@info Password not updated. Error : %" E
20+
Otherwise
21+
// Unknown e-mail: continue to the OTP form all the same, with an OTP nobody
22+
// received, so the response does not reveal whether an account exists
23+
Log "@info No user found for the submitted e-mail"
24+
unguessable = Call java.util.UUID#randomUUID
25+
otp = Call unguessable toString
26+
// OTP form feedback
27+
otpFormFeedback = {}
28+
// Max 3 times repeat
29+
Repeat 3 times max
30+
// OTP Form
31+
otpFormData = RRF "otp.ftlh" otpFormFeedback
32+
// If OTP match
33+
When otpFormData.passcode is otp
34+
// OTP matches
35+
Log "@info OTP matches"
36+
// Assign variable Re-set Password Form Feedback
37+
resetPassFormFeedback = {}
38+
// Max 3 times repeat
39+
Repeat 3 times max
40+
// Re-set Password Form
41+
passFormData = RRF "passwordForm.ftlh" resetPassFormFeedback
42+
// Check password policy
43+
isPassPolicyMatch = Call resetService passwordPolicyMatch passFormData.password
44+
// Password policy Match
45+
When isPassPolicyMatch is true
46+
// Password policy match
47+
Log "@info Password policy match"
48+
// if password match
49+
When passFormData.password is passFormData.confirmPassword
50+
// Password and confirmPassword match
51+
Log "@info Password and confirmPassword match"
52+
// Update user password
53+
inum | E = Call resetService updateUserPassword passFormData.password mailForm.mail
54+
// If password update successfully
55+
When inum is not null
56+
// Password update successfully
57+
Log "@info Password update successfully"
58+
// acknowledgement
59+
acknowledgement = RRF "acknowledgement.ftlh"
60+
// Flow finished successfully
61+
Finish user.uid
5962
Otherwise
60-
// Password doesn't match
61-
resetPassFormFeedback.errorMessage = "Password doesn't match"
63+
// Password not updated
64+
Log "@info Password not updated. Error : %" E
6265
Otherwise
63-
// Password Policy
64-
resetPassFormFeedback.errorMessage = "Password must be at least 12 characters long and contain at least one upper, lower case, special character and digit"
65-
Otherwise
66-
// OTP doesn't match
67-
otpFormFeedback.errorMessage = "OTP doesn't match"
68-
Otherwise
69-
// User not found
70-
mailUIFeedback.errorMessage = "User not found"
66+
// Password doesn't match
67+
resetPassFormFeedback.errorMessage = "Password doesn't match"
68+
Otherwise
69+
// Password Policy
70+
resetPassFormFeedback.errorMessage = "Password must be at least 12 characters long and contain at least one upper, lower case, special character and digit"
71+
Otherwise
72+
// OTP doesn't match
73+
otpFormFeedback.errorMessage = "OTP doesn't match"
7174
// Max attempts reached
7275
Log "@info Max attempts reached"
7376
// Max attempts reached

‎jans-config-api/plugins/admin-ui-plugin/agama/project/lib/org/gluu/agama/pw/PasswordService.java‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ public abstract class PasswordService {
1010

1111
public abstract String lockAccount(String username);
1212

13+
public abstract String getAuthenticatedUserId();
14+
1315
public static PasswordService getInstance(HashMap config) {
1416
return new JansPasswordService(config);
1517
}

0 commit comments

Comments
 (0)