Class: Zitadel::Client::Auth::OpenId
- Inherits:
-
Object
- Object
- Zitadel::Client::Auth::OpenId
- Defined in:
- lib/zitadel/client/auth/open_id.rb
Overview
OpenId retrieves OpenID Connect configuration from a given host.
It builds the well-known configuration URL from the provided hostname, fetches the configuration, and extracts the token endpoint.
Instance Attribute Summary collapse
-
#host_endpoint ⇒ Object
Returns the value of attribute host_endpoint.
-
#token_endpoint ⇒ Object
Returns the value of attribute token_endpoint.
Class Method Summary collapse
-
.build_well_known_url(hostname) ⇒ String
Builds the well-known OpenID configuration URL for the given hostname.
Instance Method Summary collapse
-
#initialize(hostname) ⇒ OpenId
constructor
Initializes a new OpenId instance.
Constructor Details
#initialize(hostname) ⇒ OpenId
Initializes a new OpenId instance.
noinspection HttpUrlsUsage
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/zitadel/client/auth/open_id.rb', line 26 def initialize(hostname) hostname = "https://#{hostname}" unless hostname.start_with?('http://', 'https://') @host_endpoint = hostname well_known_url = self.class.build_well_known_url(hostname) uri = URI.parse(well_known_url) response = Net::HTTP.get_response(uri) raise "Failed to fetch OpenID configuration: HTTP #{response.code}" unless response.code.to_i == 200 config = JSON.parse(response.body) token_endpoint = config['token_endpoint'] raise 'token_endpoint not found in OpenID configuration' unless token_endpoint @token_endpoint = token_endpoint end |
Instance Attribute Details
#host_endpoint ⇒ Object
Returns the value of attribute host_endpoint.
17 18 19 |
# File 'lib/zitadel/client/auth/open_id.rb', line 17 def host_endpoint @host_endpoint end |
#token_endpoint ⇒ Object
Returns the value of attribute token_endpoint.
17 18 19 |
# File 'lib/zitadel/client/auth/open_id.rb', line 17 def token_endpoint @token_endpoint end |
Class Method Details
.build_well_known_url(hostname) ⇒ String
Builds the well-known OpenID configuration URL for the given hostname.
48 49 50 |
# File 'lib/zitadel/client/auth/open_id.rb', line 48 def self.build_well_known_url(hostname) URI.join(hostname, '/.well-known/openid-configuration').to_s end |