Class: Keyrod::OIDCClient
- Inherits:
-
Object
- Object
- Keyrod::OIDCClient
- Defined in:
- lib/keyrod/oidc_client.rb
Instance Attribute Summary collapse
-
#client_id ⇒ Object
readonly
Returns the value of attribute client_id.
-
#client_secret ⇒ Object
readonly
Returns the value of attribute client_secret.
-
#oidc_site ⇒ Object
readonly
Returns the value of attribute oidc_site.
-
#refresh_token ⇒ Object
readonly
Returns the value of attribute refresh_token.
-
#ssl ⇒ Object
readonly
Returns the value of attribute ssl.
Instance Method Summary collapse
- #access_token ⇒ Object
-
#initialize ⇒ OIDCClient
constructor
A new instance of OIDCClient.
Constructor Details
#initialize ⇒ OIDCClient
Returns a new instance of OIDCClient.
8 9 10 11 12 13 14 |
# File 'lib/keyrod/oidc_client.rb', line 8 def initialize @oidc_site = Keyrod::Settings[:'oidc-site'] @refresh_token = Keyrod::Settings[:'refresh-token'] @client_id = Keyrod::Settings[:'client-id'] @client_secret = Keyrod::Settings[:'client-secret'] @ssl = Keyrod::Settings[:ssl] end |
Instance Attribute Details
#client_id ⇒ Object (readonly)
Returns the value of attribute client_id.
6 7 8 |
# File 'lib/keyrod/oidc_client.rb', line 6 def client_id @client_id end |
#client_secret ⇒ Object (readonly)
Returns the value of attribute client_secret.
6 7 8 |
# File 'lib/keyrod/oidc_client.rb', line 6 def client_secret @client_secret end |
#oidc_site ⇒ Object (readonly)
Returns the value of attribute oidc_site.
6 7 8 |
# File 'lib/keyrod/oidc_client.rb', line 6 def oidc_site @oidc_site end |
#refresh_token ⇒ Object (readonly)
Returns the value of attribute refresh_token.
6 7 8 |
# File 'lib/keyrod/oidc_client.rb', line 6 def refresh_token @refresh_token end |
#ssl ⇒ Object (readonly)
Returns the value of attribute ssl.
6 7 8 |
# File 'lib/keyrod/oidc_client.rb', line 6 def ssl @ssl end |
Instance Method Details
#access_token ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/keyrod/oidc_client.rb', line 16 def access_token conn = Faraday.new(oidc_site, ssl: ssl, params: params) logger.debug "access_token: Sending request with params #{conn.params}" response = conn.post logger.debug "Received response with code #{response.status} and body #{response.body}" raise Keyrod::Errors::ResponseError, "Response from OIDC server was #{response.status}" unless response.success? JSON.parse(response.body, symbolize_names: true)[:access_token] end |