Class: PEClient::Resource::RBACV1::Tokens
- Defined in:
- lib/pe_client/resources/rbac.v1/tokens.rb
Overview
Authentication tokens control access to PE services. Use the auth/token and tokens endpoints to create tokens.
Instance Method Summary collapse
-
#create(lifetime:, description:, client: "PEClient/#{PEClient::VERSION}") ⇒ Hash
Create a token for the authenticated user.
-
#generate(login:, password:, lifetime: nil, label: nil) ⇒ Hash
Generate an authorization token for a user identified by login and password.
Methods inherited from Base
Constructor Details
This class inherits a constructor from PEClient::Resource::Base
Instance Method Details
#create(lifetime:, description:, client: "PEClient/#{PEClient::VERSION}") ⇒ Hash
Create a token for the authenticated user. Doesn’t allow certificate authentication.
51 52 53 |
# File 'lib/pe_client/resources/rbac.v1/tokens.rb', line 51 def create(lifetime:, description:, client: "PEClient/#{PEClient::VERSION}") @client.post "#{RBACV1::BASE_PATH}/tokens", body: {lifetime:, description:, client:}.compact end |
#generate(login:, password:, lifetime: nil, label: nil) ⇒ Hash
Note:
PEClient::Client.api_key is not required to use this method.
Generate an authorization token for a user identified by login and password. This token can be used to authenticate requests to Puppet Enterprise (PE) services, such as by using an X-Authentication header or a token query parameter in an API request.
38 39 40 |
# File 'lib/pe_client/resources/rbac.v1/tokens.rb', line 38 def generate(login:, password:, lifetime: nil, label: nil) @client.post "#{RBACV1::BASE_PATH}/auth/token", body: {login:, password:, lifetime:, label:}.compact end |