Skip to content

Commit 871ce9c

Browse files
chore: should not lowercase org_name claim (#499)
1 parent 507462f commit 871ce9c

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

EXAMPLES.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ In particular:
178178

179179
- The issuer (iss) claim should be checked to ensure the token was issued by Auth0
180180

181-
- the `org_id` or `org_name` claim should be checked to ensure it is a value that is already known to the application. Which claim you check depends on the organization value being validated: if it starts with `org_`, validate against the `org_id` claim. Otherwise, validate against `org_name`. Further, `org_name` validation should be done using a **case-insensitive** check, whereas `org_id` should be an exact case-sensitive match.
181+
- the `org_id` or `org_name` claim should be checked to ensure it is a value that is already known to the application. Which claim you check depends on the organization value being validated: if it starts with `org_`, validate against the `org_id` claim. Otherwise, validate against `org_name`. Further, the value of the `org_name` claim will always be lowercase. To aid the developer experience, you may also lowercase the input organization name when checking against the `org_name`, but do not modify the `org_name` claim value.
182182

183183
This could be validated against a known list of organization IDs or names, or perhaps checked in conjunction with the current request URL. e.g. the sub-domain may hint at what organization should be used to validate the Access Token.
184184

lib/auth0/mixins/validation.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ def validate_org(claims, expected)
204204
raise Auth0::InvalidIdToken, 'Organization Name (org_name) claim must be a string present in the ID token'
205205
end
206206

207-
unless expected.downcase == claims['org_name'].downcase
207+
unless expected.downcase == claims['org_name']
208208
raise Auth0::InvalidIdToken, "Organization Name (org_name) claim value mismatch in the ID token; expected \"#{expected}\","\
209209
" found \"#{claims['org_name']}\""
210210
end

spec/lib/auth0/mixins/validation_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -342,8 +342,8 @@ def build_id_token(payload = {})
342342
end
343343

344344
it 'is expected to NOT raise an error with organization name in different casing' do
345-
token = build_id_token org_name: 'MY-ORGANIZATION'
346-
instance = Auth0::Mixins::Validation::IdTokenValidator.new(CONTEXT.merge({ organization: 'my-organization' }))
345+
token = build_id_token org_name: 'my-organization'
346+
instance = Auth0::Mixins::Validation::IdTokenValidator.new(CONTEXT.merge({ organization: 'MY-ORGANIZATION' }))
347347

348348
expect { instance.validate(token) }.not_to raise_exception
349349
end

0 commit comments

Comments
 (0)