跳至内容 跳至搜索
方法
A
R

实例公共方法

authenticate_or_request_with_http_token(realm = "Application", message = nil, &login_procedure)

使用 HTTP Bearer 令牌进行身份验证,否则会渲染一个 HTTP 标头,要求客户端发送 Bearer 令牌。要使身份验证被视为成功,login_procedure 的返回值不得为 false。通常,它会返回已认证的用户。

有关示例用法,请参阅 ActionController::HttpAuthentication::Token

# File actionpack/lib/action_controller/metal/http_authentication.rb, line 438
def authenticate_or_request_with_http_token(realm = "Application", message = nil, &login_procedure)
  authenticate_with_http_token(&login_procedure) || request_http_token_authentication(realm, message)
end

authenticate_with_http_token(&login_procedure)

使用 HTTP Bearer 令牌进行身份验证。如果找到令牌,则返回 login_procedure 的返回值。如果未找到令牌,则返回 nil

有关示例用法,请参阅 ActionController::HttpAuthentication::Token

# File actionpack/lib/action_controller/metal/http_authentication.rb, line 446
def authenticate_with_http_token(&login_procedure)
  Token.authenticate(self, &login_procedure)
end

request_http_token_authentication(realm = "Application", message = nil)

渲染一个 HTTP 标头,要求客户端发送 Bearer 令牌进行身份验证。

# File actionpack/lib/action_controller/metal/http_authentication.rb, line 452
def request_http_token_authentication(realm = "Application", message = nil)
  Token.authentication_request(self, realm, message)
end