Class: Stormpath::Rails::ControllerAuthentication::FromBearerAuth

Inherits:
Object
  • Object
show all
Defined in:
app/services/stormpath/rails/controller_authentication/from_bearer_auth.rb

Constant Summary collapse

RESCUE_CLASSES =
[
  Stormpath::Oauth::Error,
  JWT::DecodeError,
  AccountFromAccessToken::AuthenticationWithRefreshTokenAttemptError,
  AccountFromAccessToken::DifferentIssuerError
].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(authorization_header) ⇒ FromBearerAuth

Returns a new instance of FromBearerAuth.



14
15
16
# File 'app/services/stormpath/rails/controller_authentication/from_bearer_auth.rb', line 14

def initialize(authorization_header)
  @authorization_header = authorization_header
end

Instance Attribute Details

#authorization_headerObject (readonly)

Returns the value of attribute authorization_header.



5
6
7
# File 'app/services/stormpath/rails/controller_authentication/from_bearer_auth.rb', line 5

def authorization_header
  @authorization_header
end

Instance Method Details

#authenticate!Object



18
19
20
21
22
23
24
# File 'app/services/stormpath/rails/controller_authentication/from_bearer_auth.rb', line 18

def authenticate!
  begin
    AccountFromAccessToken.new(bearer_access_token).
  rescue *RESCUE_CLASSES
    raise UnauthenticatedRequest
  end
end