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

实例公共方法

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

使用 HTTP Bearer 令牌进行身份验证,或以其他方式呈现 HTTP 标头,请求客户端发送 Bearer 令牌。要将身份验证视为成功,login_procedure 应返回一个非 nil 值。通常,会返回经过身份验证的用户。

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

# File actionpack/lib/action_controller/metal/http_authentication.rb, line 432
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 441
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 447
def request_http_token_authentication(realm = "Application", message = nil)
  Token.authentication_request(self, realm, message)
end