Skip to content

Commit

Permalink
raw_header support, version bump
Browse files Browse the repository at this point in the history
  • Loading branch information
sardaukar committed Sep 9, 2024
1 parent 0288eb3 commit 0ced236
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
6 changes: 6 additions & 0 deletions lib/warden/jwt_auth.rb
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,12 @@ def self.jwks
default: nil,
constructor: ->(value) { init_jkws_loader(value) })

# If JWT header should be parsed "raw" ie without `Bearer xxxxx` and just `xxxxx`
#
# @example
# [true]
setting(:raw_header, default: false)

Import = Dry::AutoInject(config)
end
end
Expand Down
8 changes: 6 additions & 2 deletions lib/warden/jwt_auth/header_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@ def self.from_env(env)
auth = EnvHelper.authorization_header(env)
return nil unless auth

method, token = auth.split
method == METHOD ? token : nil
if JWTAuth.config.raw_header
auth
else
method, token = auth.split
method == METHOD ? token : nil
end
end

# Returns a copy of `env` with token added to the header configured through
Expand Down
2 changes: 1 addition & 1 deletion lib/warden/jwt_auth/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

module Warden
module JWTAuth
VERSION = '0.12.3'
VERSION = '0.12.4'
end
end

0 comments on commit 0ced236

Please sign in to comment.