Class: Keycardai::MCP::AuthProvider::Grant
- Inherits:
-
Object
- Object
- Keycardai::MCP::AuthProvider::Grant
- Defined in:
- lib/keycardai/mcp/auth_provider.rb
Overview
The middleware realizing a grant declaration. Not used directly; constructed through AuthProvider#grant.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, provider:, resources:, user_identifier:, request_scopes:) ⇒ Grant
constructor
A new instance of Grant.
Constructor Details
#initialize(app, provider:, resources:, user_identifier:, request_scopes:) ⇒ Grant
Returns a new instance of Grant.
109 110 111 112 113 114 115 |
# File 'lib/keycardai/mcp/auth_provider.rb', line 109 def initialize(app, provider:, resources:, user_identifier:, request_scopes:) @app = app @provider = provider @resources = resources @user_identifier = user_identifier @request_scopes = request_scopes end |
Instance Method Details
#call(env) ⇒ Object
117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/keycardai/mcp/auth_provider.rb', line 117 def call(env) auth_info = env[ENV_AUTH_INFO] return RackSupport.challenge_response(env, status: 401) if auth_info.nil? context = env[ENV_ACCESS_CONTEXT] || Keycardai::OAuth::AccessContext.new @provider.exchange_tokens( auth_info.token, @resources, access_context: context, user_identifier: resolve_user(env), request_scopes: @request_scopes ) env[ENV_ACCESS_CONTEXT] = context @app.call(env) end |