Module: ActionController::HttpAuthentication::Token::ControllerMethods
| Relationships & Source Files | |
| Extension / Inclusion / Inheritance Descendants | |
|
Included In:
| |
| Defined in: | actionpack/lib/action_controller/metal/http_authentication.rb |
Instance Method Summary
-
#authenticate_or_request_with_http_token(realm = "Application", message = nil, content_type = nil, scheme: nil, &login_procedure)
Authenticate using an HTTP token, or otherwise render an HTTP header requesting the client to send a token.
-
#authenticate_with_http_token(scheme: nil, &login_procedure)
Authenticate using an HTTP token.
-
#request_http_token_authentication(realm = "Application", message = nil, content_type = nil, scheme: nil)
Render an HTTP header requesting the client to send a token for authentication.
Instance Method Details
#authenticate_or_request_with_http_token(realm = "Application", message = nil, content_type = nil, scheme: nil, &login_procedure)
Authenticate using an HTTP token, or otherwise render an HTTP header
requesting the client to send a token. For the authentication to be
considered successful, login_procedure must not return a false value.
Typically, the authenticated user is returned.
The optional scheme restricts authentication to that scheme (or any of
them, when given an array) and uses it verbatim for the WWW-Authenticate
response header. Any scheme name can be required. When no scheme is
given, "Token", "Bearer", and "DPoP" are accepted. The request's
authentication scheme is yielded as a downcased symbol in an optional
third argument to login_procedure.
See ::ActionController::HttpAuthentication::Token for example usage.
# File 'actionpack/lib/action_controller/metal/http_authentication.rb', line 449
def authenticate_or_request_with_http_token(realm = "Application", = nil, content_type = nil, scheme: nil, &login_procedure) authenticate_with_http_token(scheme:, &login_procedure) || request_http_token_authentication(realm, , content_type, scheme:) end
#authenticate_with_http_token(scheme: nil, &login_procedure)
Authenticate using an HTTP token. Returns the return value of
login_procedure if a token is found. Returns nil if no token is found.
See ::ActionController::HttpAuthentication::Token for example usage.
# File 'actionpack/lib/action_controller/metal/http_authentication.rb', line 457
def authenticate_with_http_token(scheme: nil, &login_procedure) Token.authenticate(self, scheme:, &login_procedure) end
#request_http_token_authentication(realm = "Application", message = nil, content_type = nil, scheme: nil)
Render an HTTP header requesting the client to send a token for authentication.
# File 'actionpack/lib/action_controller/metal/http_authentication.rb', line 463
def request_http_token_authentication(realm = "Application", = nil, content_type = nil, scheme: nil) Token.authentication_request(self, realm, , content_type, scheme:) end