Skip to content

Commit

Permalink
Support hyphens in claims used for AuthnJWT
Browse files Browse the repository at this point in the history
  • Loading branch information
john-odonnell committed May 3, 2023
1 parent 6bb8ad4 commit f9be98d
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/domain/authentication/authn_jwt/consts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ module AuthnJwt
CLAIMS_CHARACTER_DELIMITER = ","
TUPLE_CHARACTER_DELIMITER = ":"

PURE_CLAIM_NAME_REGEX = /[a-zA-Z|$|_][a-zA-Z|$|_|0-9|.]*/.freeze
PURE_CLAIM_NAME_REGEX = /[a-zA-Z|$|_][a-zA-Z|$|_|\-|0-9|.]*/.freeze
PURE_NESTED_CLAIM_NAME_REGEX = /^#{PURE_CLAIM_NAME_REGEX.source}(#{PATH_DELIMITER}#{PURE_CLAIM_NAME_REGEX.source})*$/.freeze

SIGNING_KEY_RESOURCES_NAMES = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ Feature: JWT Authenticator - Token Schema
Then the HTTP response status code is 401
And The following appears in the log after my savepoint:
"""
CONJ00104E Failed to validate claim: claim name '%@^#[{]}$~=-+_?.><&^@*@#*sdhj812ehd' does not match regular expression: '(?-mix:^[a-zA-Z|$|_][a-zA-Z|$|_|0-9|.]*(\/[a-zA-Z|$|_][a-zA-Z|$|_|0-9|.]*)*$)'.>
CONJ00104E Failed to validate claim: claim name '%@^#[{]}$~=-+_?.><&^@*@#*sdhj812ehd' does not match regular expression: '(?-mix:^[a-zA-Z|$|_][a-zA-Z|$|_|\-|0-9|.]*(\/[a-zA-Z|$|_][a-zA-Z|$|_|\-|0-9|.]*)*$)'.>
"""

@negative @acceptance
Expand Down Expand Up @@ -732,7 +732,7 @@ Feature: JWT Authenticator - Token Schema
Then the HTTP response status code is 401
And The following appears in the log after my savepoint:
"""
CONJ00104E Failed to validate claim: claim name '%@^#&^[{]}$~=-+_?.><812ehd' does not match regular expression: '(?-mix:^[a-zA-Z|$|_][a-zA-Z|$|_|0-9|.]*(\/[a-zA-Z|$|_][a-zA-Z|$|_|0-9|.]*)*$)'.
CONJ00104E Failed to validate claim: claim name '%@^#&^[{]}$~=-+_?.><812ehd' does not match regular expression: '(?-mix:^[a-zA-Z|$|_][a-zA-Z|$|_|\-|0-9|.]*(\/[a-zA-Z|$|_][a-zA-Z|$|_|\-|0-9|.]*)*$)'.
"""

@acceptance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1108,7 +1108,7 @@ Feature: JWT Authenticator - Status Check
And I save my place in the log file
When I GET "/authn-jwt/raw/cucumber/status"
Then the HTTP response status code is 500
And the authenticator status check fails with error "does not match regular expression: '(?-mix:^[a-zA-Z|$|_][a-zA-Z|$|_|0-9|.]*(\/[a-zA-Z|$|_][a-zA-Z|$|_|0-9|.]*)*$)"
And the authenticator status check fails with error "does not match regular expression: '(?-mix:^[a-zA-Z|$|_][a-zA-Z|$|_|-|0-9|.]*(\/[a-zA-Z|$|_][a-zA-Z|$|_|-|0-9|.]*)*$)"

@negative @acceptance
Scenario Outline: ONYX-10958: claim-aliases configured with invalid value, 500 Error
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
"When claim name is 1 dot character '.'": [".", Errors::Authentication::AuthnJwt::FailedToValidateClaimForbiddenClaimName],
"When claim name is just 1 forbidden character '*'": ["*", Errors::Authentication::AuthnJwt::FailedToValidateClaimForbiddenClaimName],
"When claim name contains 1 forbidden character '*'": ["a*b", Errors::Authentication::AuthnJwt::FailedToValidateClaimForbiddenClaimName],
"When claim name contains 1 forbidden character '-": ["a-b", Errors::Authentication::AuthnJwt::FailedToValidateClaimForbiddenClaimName],
"When claim name contains 1 forbidden character '%'": ["a%b", Errors::Authentication::AuthnJwt::FailedToValidateClaimForbiddenClaimName],
"When claim name contains 1 forbidden character '!'": ["a!b", Errors::Authentication::AuthnJwt::FailedToValidateClaimForbiddenClaimName],
"When claim name contains 1 forbidden character '('": ["a(b", Errors::Authentication::AuthnJwt::FailedToValidateClaimForbiddenClaimName],
Expand All @@ -44,7 +43,6 @@
"When claim name contains spaces": ["claim name", Errors::Authentication::AuthnJwt::FailedToValidateClaimForbiddenClaimName],
"When input has illegal [ character in claim name": ["my[claim", Errors::Authentication::AuthnJwt::FailedToValidateClaimForbiddenClaimName],
"When input has illegal [ ] characters in claim name": ["my[1]claim", Errors::Authentication::AuthnJwt::FailedToValidateClaimForbiddenClaimName],
"When input has illegal - character in claim name": ["my-claim", Errors::Authentication::AuthnJwt::FailedToValidateClaimForbiddenClaimName],
"When input has illegal : character in claim name": ["a:", Errors::Authentication::AuthnJwt::FailedToValidateClaimForbiddenClaimName]
}

Expand All @@ -53,6 +51,7 @@
"When claim name contains 1 allowed char 'f'": "f",
"When claim name contains 1 allowed char '_'": "_",
"When claim name contains value with allowed char '/'": "a/a",
"When claim name contains value with allowed char '-'": "a-b",
"When claim name contains value with multiple allowed chars '/'": "a/a/a/a",
"When claim name contains 1 allowed char '$'": "$",
"When claim name contains digits in the middle": "$2w",
Expand Down

0 comments on commit f9be98d

Please sign in to comment.