Class: Zitadel::Client::Auth::WebTokenAuthenticator::WebTokenAuthenticatorBuilder

Inherits:
OAuthAuthenticatorBuilder show all
Defined in:
lib/zitadel/client/auth/web_token_authenticator.rb

Overview

Builder for WebTokenAuthenticator.

Provides a fluent API for configuring and constructing a WebTokenAuthenticator instance.

Instance Method Summary collapse

Methods inherited from OAuthAuthenticatorBuilder

#scopes

Constructor Details

#initialize(host, jwt_issuer, jwt_subject, jwt_audience, private_key, transport_options: nil) ⇒ WebTokenAuthenticatorBuilder

Initializes the WebTokenAuthenticatorBuilder with required parameters.

rubocop:disable Metrics/ParameterLists

Parameters:

  • host (String)

    The base URL for API endpoints.

  • jwt_issuer (String)

    The issuer claim for the JWT.

  • jwt_subject (String)

    The subject claim for the JWT.

  • jwt_audience (String)

    The audience claim for the JWT.

  • private_key (String)

    The PEM-formatted private key used for signing the JWT.

  • transport_options (TransportOptions, nil) (defaults to: nil)

    Optional transport options for TLS, proxy, and headers.



147
148
149
150
151
152
153
154
155
# File 'lib/zitadel/client/auth/web_token_authenticator.rb', line 147

def initialize(host, jwt_issuer, jwt_subject, jwt_audience, private_key, transport_options: nil)
  # noinspection RubyArgCount
  super(host, transport_options: transport_options)
  @jwt_issuer = jwt_issuer
  @jwt_subject = jwt_subject
  @jwt_audience = jwt_audience
  @private_key = private_key
  @jwt_lifetime = 3600
end

Instance Method Details

#buildWebTokenAuthenticator

Constructs and returns a new WebTokenAuthenticator instance using the configured parameters.

Returns:



175
176
177
178
179
# File 'lib/zitadel/client/auth/web_token_authenticator.rb', line 175

def build
  WebTokenAuthenticator.new(open_id, auth_scopes, @jwt_issuer, @jwt_subject, @jwt_audience,
                            @private_key, jwt_lifetime: @jwt_lifetime, key_id: @key_id,
                                          transport_options: @transport_options)
end

#key_identifier(key_id) ⇒ Object



167
168
169
170
# File 'lib/zitadel/client/auth/web_token_authenticator.rb', line 167

def key_identifier(key_id)
  @key_id = key_id
  self
end

#token_lifetime_seconds(seconds) ⇒ WebTokenAuthenticatorBuilder

Sets the JWT token lifetime in seconds.

Parameters:

  • seconds (Integer)

    Lifetime of the JWT in seconds.

Returns:



162
163
164
165
# File 'lib/zitadel/client/auth/web_token_authenticator.rb', line 162

def token_lifetime_seconds(seconds)
  @jwt_lifetime = seconds
  self
end