Sha256: 185e5f43f4cfb650df59fdf4115b6c004f4bf356a79feed53c1e2a5661c412b4

Contents?: true

Size: 861 Bytes

Versions: 4

Compression:

Stored size: 861 Bytes

Contents

module Oa2c
  module Authentication
    def current_token
      @current_token
    end

    def current_client
      @current_client
    end

    def require_oauth_token
      @current_token = request.env[Rack::OAuth2::Server::Resource::ACCESS_TOKEN]
      raise Rack::OAuth2::Server::Resource::Bearer::Unauthorized unless @current_token
    end

    def require_oauth_user_token
      require_oauth_token
      raise Rack::OAuth2::Server::Resource::Bearer::Unauthorized.new(:invalid_token, 'User token is required') unless current_token.user
      send Oa2c.login_method, current_token.user
    end

    def require_oauth_client_token
      require_oauth_token
      raise Rack::OAuth2::Server::Resource::Bearer::Unauthorized.new(:invalid_token, 'Client token is required') if current_token.user
      @current_client = current_token.client
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
oa2c-0.1.2 lib/oa2c/authentication.rb
oa2c-0.1.1 lib/oa2c/authentication.rb
oa2c-0.1.0 lib/oa2c/authentication.rb
oa2c-0.0.2 lib/oa2c/authentication.rb