Module: TinyAuth

Defined in:
lib/tiny_auth.rb,
lib/tiny_auth/model.rb,
lib/tiny_auth/version.rb,
lib/tiny_auth/controller.rb

Defined Under Namespace

Modules: Model Classes: Controller

Constant Summary collapse

VERSION =
"2.0.0"

Class Method Summary collapse

Class Method Details

.hexdigest(value) ⇒ String

Create a hash from a value using the secret

Parameters:

  • value (String)

Returns:

  • (String)


28
29
30
# File 'lib/tiny_auth.rb', line 28

def hexdigest(value)
  OpenSSL::HMAC.hexdigest("SHA256", secret, value)
end

.secretString

A secret that is used for hashing tokens.

If Rails is defined, it will attempt to use Rails.application.secret_key_base.

Returns:

  • (String)

Raises:

  • (RuntimeError)


15
16
17
# File 'lib/tiny_auth.rb', line 15

def secret
  @secret || secret_key_base || missing_secret!
end

.secret=(secret) ⇒ Object

Configure the secret that is used for hashing tokens.

Parameters:

  • secret (String)


21
22
23
# File 'lib/tiny_auth.rb', line 21

def secret=(secret)
  @secret = secret
end