Skip to content

Commit

Permalink
Add audience to token claims and optimize response
Browse files Browse the repository at this point in the history
Includes an "aud" claim to access tokens for improved validation and configuration of a default audience URL in the settings. Changes `context.response.write` to `context.response.print` for efficiency in response handling. These adjustments enhance security and performance consistency across the system.
  • Loading branch information
eliasjpr committed Oct 12, 2024
1 parent 1ef3e5d commit 77d03fc
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/authly/access_token.cr
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ module Authly
"exp" => ACCESS_TTL.from_now.to_unix,
"scope" => @scope,
"jti" => @jti, # Include the jti in the token claims
"aud" => Authly.config.audience,
})
end

Expand Down
1 change: 1 addition & 0 deletions src/authly/configuration.cr
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ module Authly
property algorithm : JWT::Algorithm = JWT::Algorithm::HS256
property token_strategy : Symbol = :jwt
property state_store : StateStore = InMemoryStateStore.new
property audience : String = "https://your-domain.com/oauth/token"
end
end
2 changes: 1 addition & 1 deletion src/authly/handlers/response_helper.cr
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module Authly
def self.write(context, status_code, content_type = "text/plain", body = "")
context.response.status_code = status_code
context.response.content_type = content_type
context.response.write body
context.response.print body
end

def self.redirect(context, location)
Expand Down

0 comments on commit 77d03fc

Please sign in to comment.