Class: OAuth2::MCP::AuthorizationResult
- Inherits:
-
Object
- Object
- OAuth2::MCP::AuthorizationResult
- Defined in:
- lib/oauth2/mcp.rb
Overview
Result object returned by resource-server authorization checks.
Instance Attribute Summary collapse
-
#capabilities ⇒ Object
readonly
Returns the value of attribute capabilities.
-
#challenge ⇒ Object
readonly
Returns the value of attribute challenge.
-
#claims ⇒ Object
readonly
Returns the value of attribute claims.
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#error_description ⇒ Object
readonly
Returns the value of attribute error_description.
-
#required_scopes ⇒ Object
readonly
Returns the value of attribute required_scopes.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Class Method Summary collapse
-
.allow(claims:, capabilities: []) ⇒ Object
-
.deny(status:, error:, error_description:, required_scopes:, challenge:) ⇒ Object
Instance Method Summary collapse
-
#allowed? ⇒ Boolean
-
#headers ⇒ Object
-
#initialize(allowed:, **attributes) ⇒ AuthorizationResult
constructor
A new instance of AuthorizationResult.
Constructor Details
#initialize(allowed:, **attributes) ⇒ AuthorizationResult
Returns a new instance of AuthorizationResult.
373 374 375 376 377 378 379 380 381 382 |
# File 'lib/oauth2/mcp.rb', line 373 def initialize(allowed:, **attributes) @allowed = allowed @claims = attributes[:claims] @capabilities = Array(attributes[:capabilities]).map(&:to_s).freeze @status = attributes[:status] @error = attributes[:error] @error_description = attributes[:error_description] @required_scopes = Array(attributes[:required_scopes]).map(&:to_s).freeze @challenge = attributes[:challenge] end |
Instance Attribute Details
#capabilities ⇒ Object (readonly)
Returns the value of attribute capabilities.
354 355 356 |
# File 'lib/oauth2/mcp.rb', line 354 def capabilities @capabilities end |
#challenge ⇒ Object (readonly)
Returns the value of attribute challenge.
354 355 356 |
# File 'lib/oauth2/mcp.rb', line 354 def challenge @challenge end |
#claims ⇒ Object (readonly)
Returns the value of attribute claims.
354 355 356 |
# File 'lib/oauth2/mcp.rb', line 354 def claims @claims end |
#error ⇒ Object (readonly)
Returns the value of attribute error.
354 355 356 |
# File 'lib/oauth2/mcp.rb', line 354 def error @error end |
#error_description ⇒ Object (readonly)
Returns the value of attribute error_description.
354 355 356 |
# File 'lib/oauth2/mcp.rb', line 354 def error_description @error_description end |
#required_scopes ⇒ Object (readonly)
Returns the value of attribute required_scopes.
354 355 356 |
# File 'lib/oauth2/mcp.rb', line 354 def required_scopes @required_scopes end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
354 355 356 |
# File 'lib/oauth2/mcp.rb', line 354 def status @status end |
Class Method Details
.allow(claims:, capabilities: []) ⇒ Object
357 358 359 |
# File 'lib/oauth2/mcp.rb', line 357 def allow(claims:, capabilities: []) new(allowed: true, claims: claims, capabilities: capabilities) end |
.deny(status:, error:, error_description:, required_scopes:, challenge:) ⇒ Object
361 362 363 364 365 366 367 368 369 370 |
# File 'lib/oauth2/mcp.rb', line 361 def deny(status:, error:, error_description:, required_scopes:, challenge:) new( allowed: false, status: status, error: error, error_description: error_description, required_scopes: required_scopes, challenge: challenge, ) end |
Instance Method Details
#allowed? ⇒ Boolean
384 385 386 |
# File 'lib/oauth2/mcp.rb', line 384 def allowed? @allowed end |
#headers ⇒ Object
388 389 390 391 392 |
# File 'lib/oauth2/mcp.rb', line 388 def headers return {} unless challenge {"WWW-Authenticate" => challenge.to_header} end |