Module: RubyJwk::Authenticate
- Defined in:
- app/controllers/concerns/ruby_jwk/authenticate.rb
Instance Method Summary collapse
Instance Method Details
#authenticate_tenant! ⇒ Object
3 4 5 6 7 8 9 |
# File 'app/controllers/concerns/ruby_jwk/authenticate.rb', line 3 def authenticate_tenant! return if RubyJwk.skip_issuers.to_a.include?(jwt_payload['iss']) JWT.decode(jwt_token, nil, true, { algorithm: 'RS256', jwks: jwk_loader}) rescue JWT::DecodeError => e render status: 401, json: error_response_template("Authentication failed! - #{e.message}") end |
#jwt_payload ⇒ Object
11 12 13 14 15 |
# File 'app/controllers/concerns/ruby_jwk/authenticate.rb', line 11 def jwt_payload @jwt_payload ||= JWT.decode(jwt_token, nil, false).first rescue JWT::DecodeError => e {} end |
#jwt_tenant_name ⇒ Object
17 18 19 |
# File 'app/controllers/concerns/ruby_jwk/authenticate.rb', line 17 def jwt_tenant_name jwt_payload.dig('tenant') end |
#jwt_token ⇒ Object
21 22 23 24 25 |
# File 'app/controllers/concerns/ruby_jwk/authenticate.rb', line 21 def jwt_token return unless auth_header.starts_with?('Bearer ') auth_header.to_s.gsub('Bearer ', '') end |