Module: Cyclid::Client::Auth

Included in:
Tilapia
Defined in:
lib/cyclid/client/auth.rb

Overview

Authentication related methods

Instance Method Summary collapse

Instance Method Details

#token_get(username, claims = {}) ⇒ Hash

Retrieve a JWT token from the server.

Examples:

Request a simple token

token_data = token_get

Request a token with a CSRF injected into the claims

token_data = token_get(csrf: 'abcdef0123456789')

Parameters:

  • username (String)

    User name of the user to retrieve a token for.

  • claims (Hash) (defaults to: {})

    additional JWT claims to append to the token.

Returns:

  • (Hash)

    Decoded server response object.



29
30
31
32
33
34
35
# File 'lib/cyclid/client/auth.rb', line 29

def token_get(username, claims = {})
  uri = server_uri("/token/#{username}")
  res_data = api_json_post(uri, claims)
  @logger.debug res_data

  return res_data
end