Module: AzureJwtAuth::Authenticable

Defined in:
lib/azure_jwt_auth/authenticable.rb

Instance Method Summary collapse

Instance Method Details

#authenticate!Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/azure_jwt_auth/authenticable.rb', line 15

def authenticate!
  unauthorize! unless JwtManager.providers

  JwtManager.providers.each do |_uid, provider|
    token = JwtManager.new(request, provider.uid)

    if token.valid?
      @current_user = entity_from_token_payload(token.payload)
      break
    end
  rescue => error
    Rails.logger.info(error) if defined? Rails
  end

  unauthorize! unless @current_user
end

#current_userObject



7
8
9
# File 'lib/azure_jwt_auth/authenticable.rb', line 7

def current_user
  @current_user
end

#signed_in?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/azure_jwt_auth/authenticable.rb', line 11

def signed_in?
  !current_user.nil?
end

#unauthorize!Object

Raises:



32
33
34
# File 'lib/azure_jwt_auth/authenticable.rb', line 32

def unauthorize!
  raise NotAuthorized
end