Class: KeycloakSdk::TokenSet
- Inherits:
-
Data
- Object
- Data
- KeycloakSdk::TokenSet
- Defined in:
- lib/keycloak_sdk/tokens.rb
Overview
OAuth 토큰 응답의 불변 값타입. access/refresh/id 토큰은 inspect에서 마스킹.
Instance Attribute Summary collapse
-
#access_token ⇒ Object
readonly
Returns the value of attribute access_token.
-
#expires_at ⇒ Object
readonly
Returns the value of attribute expires_at.
-
#expires_in ⇒ Object
readonly
Returns the value of attribute expires_in.
-
#id_token ⇒ Object
readonly
Returns the value of attribute id_token.
-
#refresh_token ⇒ Object
readonly
Returns the value of attribute refresh_token.
-
#scope ⇒ Object
readonly
Returns the value of attribute scope.
-
#token_type ⇒ Object
readonly
Returns the value of attribute token_type.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#access_token ⇒ Object (readonly)
Returns the value of attribute access_token
5 6 7 |
# File 'lib/keycloak_sdk/tokens.rb', line 5 def access_token @access_token end |
#expires_at ⇒ Object (readonly)
Returns the value of attribute expires_at
5 6 7 |
# File 'lib/keycloak_sdk/tokens.rb', line 5 def expires_at @expires_at end |
#expires_in ⇒ Object (readonly)
Returns the value of attribute expires_in
5 6 7 |
# File 'lib/keycloak_sdk/tokens.rb', line 5 def expires_in @expires_in end |
#id_token ⇒ Object (readonly)
Returns the value of attribute id_token
5 6 7 |
# File 'lib/keycloak_sdk/tokens.rb', line 5 def id_token @id_token end |
#refresh_token ⇒ Object (readonly)
Returns the value of attribute refresh_token
5 6 7 |
# File 'lib/keycloak_sdk/tokens.rb', line 5 def refresh_token @refresh_token end |
#scope ⇒ Object (readonly)
Returns the value of attribute scope
5 6 7 |
# File 'lib/keycloak_sdk/tokens.rb', line 5 def scope @scope end |
#token_type ⇒ Object (readonly)
Returns the value of attribute token_type
5 6 7 |
# File 'lib/keycloak_sdk/tokens.rb', line 5 def token_type @token_type end |
Class Method Details
.from_response(body, received_at: Time.now.to_f) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/keycloak_sdk/tokens.rb', line 7 def self.from_response(body, received_at: Time.now.to_f) expires_in = body["expires_in"] && Integer(body["expires_in"]) new( access_token: body["access_token"], token_type: body["token_type"], expires_in: expires_in, refresh_token: body["refresh_token"], id_token: body["id_token"], scope: body["scope"], expires_at: expires_in ? received_at + expires_in : nil ) end |
Instance Method Details
#expired?(skew: 0, now: Time.now.to_f) ⇒ Boolean
20 21 22 23 24 |
# File 'lib/keycloak_sdk/tokens.rb', line 20 def expired?(skew: 0, now: Time.now.to_f) return false if expires_at.nil? now >= (expires_at - skew) end |
#inspect ⇒ Object Also known as: to_s
26 27 28 29 30 |
# File 'lib/keycloak_sdk/tokens.rb', line 26 def inspect "#<KeycloakSdk::TokenSet access_token=\"***\" token_type=#{token_type.inspect} " \ "expires_in=#{expires_in.inspect} refresh_token=#{refresh_token ? '"***"' : 'nil'} " \ "id_token=#{id_token ? '"***"' : 'nil'} scope=#{scope.inspect} expires_at=#{expires_at.inspect}>" end |