module Gems::ClientCredentials

Mixin for client authentication credentials, included in {Client} @api public

Attributes

The authenticator for API requests

The authenticators are internals, which can change within 3.x; a credential is changed with the setters of the client, which build the authenticator again.

@api private @return [Authenticator] the authenticator instance @example Get the authenticator

client.authenticator

The OIDC ID token for trusted publishing @api public @return [String, nil] the OIDC ID token @example Get the ID token

client.id_token

The API key @api public @return [String, nil] the API key @example Get the API key

client.key

The one-time passcode for multi-factor authentication @api public @return [String, nil] the one-time passcode @example Get the one-time passcode

client.otp

The password for HTTP basic authentication @api public @return [String, nil] the password @example Get the password

client.password

The username for HTTP basic authentication @api public @return [String, nil] the username @example Get the username

client.username

Public Instance Methods

Set the OIDC ID token for trusted publishing

@api public @param id_token [String, nil] the OIDC ID token @return [void] @example Set the ID token

client.id_token = ENV.fetch("ID_TOKEN")
# File lib/gems/client_credentials.rb, line 131
def id_token=(id_token)
  @id_token = id_token
  initialize_authenticator
end

Set the API key

@api public @param key [String, APIKey, nil] the API key, or an API key object @return [void] @example Set the API key

client.key = "rubygems_701243f217cdf23b1370c7b66b65ca97"

@example Set the API key from a newly created API key

client.key = client.create_api_key("ci-push", scopes: %i[push_rubygem])
# File lib/gems/client_credentials.rb, line 82
def key=(key)
  @key = key_of(key)
  @key_configured = true
  initialize_authenticator
end

Set the one-time passcode for multi-factor authentication

@api public @param otp [String, nil] the one-time passcode @return [void] @example Set the one-time passcode

client.otp = "123456"
# File lib/gems/client_credentials.rb, line 119
def otp=(otp)
  @otp = otp
  initialize_authenticator
end

Set the password for HTTP basic authentication

@api public @param password [String, nil] the password @return [void] @example Set the password

client.password = "schwwwwing"
# File lib/gems/client_credentials.rb, line 107
def password=(password)
  @password = password
  initialize_authenticator
end

Set the username for HTTP basic authentication

@api public @param username [String, nil] the username @return [void] @example Set the username

client.username = "nick@gemcutter.org"
# File lib/gems/client_credentials.rb, line 95
def username=(username)
  @username = username
  initialize_authenticator
end