Module: OpenIDTokenProxy::Token::Authentication
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/openid_token_proxy/token/authentication.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #current_token ⇒ Object
- #raw_token ⇒ Object
- #require_authorization(exception) ⇒ Object
- #require_valid_token ⇒ Object
- #set_authentication_url! ⇒ Object
Instance Method Details
#current_token ⇒ Object
36 37 38 |
# File 'lib/openid_token_proxy/token/authentication.rb', line 36 def current_token @current_token ||= OpenIDTokenProxy::Token.decode!(raw_token) end |
#raw_token ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/openid_token_proxy/token/authentication.rb', line 40 def raw_token token = params[:token] return token if token = request.headers['Authorization'] if token = [/Bearer (.+)/, 1] return token if token end request.headers['X-Token'] end |
#require_authorization(exception) ⇒ Object
25 26 27 28 |
# File 'lib/openid_token_proxy/token/authentication.rb', line 25 def (exception) set_authentication_url! render json: exception.to_json, status: :unauthorized end |
#require_valid_token ⇒ Object
30 31 32 33 34 |
# File 'lib/openid_token_proxy/token/authentication.rb', line 30 def require_valid_token config = OpenIDTokenProxy.config current_token.validate! audience: config.resource, client_id: config.client_id end |
#set_authentication_url! ⇒ Object
20 21 22 23 |
# File 'lib/openid_token_proxy/token/authentication.rb', line 20 def set_authentication_url! uri = OpenIDTokenProxy.client. response.headers['X-Authentication-URL'] = uri end |