Skip to content

Commit cb6d5e5

Browse files
authored
added a config value accept_audience (#24)
Intended to use in cases where the audience param shall not be the host URL Can be overwritten as before by the ENV
1 parent b83ec8b commit cb6d5e5

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

config/omejdn.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ app_env: debug
1414
# Enable OpenID funtionality
1515
openid: true
1616

17+
# Overwrite the aud claim value to accept in client's bearer tokens (defaults to host)
18+
#accept_audience:
19+
1720
# Token singing keys and default values
1821
token:
1922
expiration: 3600

lib/client.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def self.find_by_jwt(jwt)
6969

7070
puts "Client #{jwt_cid} found"
7171
# Try verify
72-
aud = ENV['OMEJDN_JWT_AUD_OVERRIDE'] || Config.base_config['host']
72+
aud = Config.base_config['accept_audience']
7373
JWT.decode jwt, client.certificate&.public_key, true,
7474
{ nbf_leeway: 30, aud: aud, verify_aud: true, algorithm: jwt_alg }
7575
return client

omejdn.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ def adjust_config
4646
base_config['bind_to'] = ENV['BIND_TO'] || base_config['bind_to'] || '0.0.0.0'
4747
base_config['allow_origin'] = ENV['ALLOW_ORIGIN'] || base_config['allow_origin'] || '*'
4848
base_config['app_env'] = ENV['APP_ENV'] || base_config['app_env'] || 'debug'
49+
base_config['accept_audience'] =
50+
ENV['OMEJDN_JWT_AUD_OVERRIDE'] || base_config['accept_audience'] || base_config['host']
4951
Config.base_config = base_config
5052
end
5153

0 commit comments

Comments
 (0)