Class: Scaled::Auth::OAuthClientCredentials
- Inherits:
-
Object
- Object
- Scaled::Auth::OAuthClientCredentials
- Defined in:
- lib/scaled/auth/oauth_client_credentials.rb
Overview
OAuth Client Credentials authentication strategy. Стратегія OAuth Client Credentials для автентифікації.
Constant Summary collapse
- DEFAULT_TOKEN_URL =
"https://api.tailscale.com/api/v2/oauth/token"- REFRESH_SAFETY_WINDOW =
30
Instance Method Summary collapse
-
#apply(headers) ⇒ Hash{String => String}
Note: mutates and returns the same hash for compatibility with HTTP layer.
-
#initialize(client_id:, client_secret:, **options) ⇒ void
constructor
Note: token refresh is automatic when expiry approaches.
Constructor Details
#initialize(client_id:, client_secret:, **options) ⇒ void
Note: token refresh is automatic when expiry approaches. Нотатка: токен оновлюється автоматично при наближенні до завершення дії.
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/scaled/auth/oauth_client_credentials.rb', line 21 def initialize(client_id:, client_secret:, **) @client_id = normalize_required(client_id, "client_id") @client_secret = normalize_required(client_secret, "client_secret") @scopes = Array(.fetch(:scopes, [])).map(&:to_s).map(&:strip).reject(&:empty?) @token_url = .fetch(:token_url, DEFAULT_TOKEN_URL) @open_timeout = .fetch(:open_timeout, 5) @read_timeout = .fetch(:read_timeout, 30) @now = .fetch(:now, -> { Time.now }) @token_data = nil end |
Instance Method Details
#apply(headers) ⇒ Hash{String => String}
Note: mutates and returns the same hash for compatibility with HTTP layer. Нотатка: змінює і повертає той самий hash для сумісності з HTTP-шаром.
36 37 38 39 |
# File 'lib/scaled/auth/oauth_client_credentials.rb', line 36 def apply(headers) headers["Authorization"] = "Bearer #{access_token}" headers end |