Class: Auth0::Mixins::Validation::Algorithm::HS256

Inherits:
JWTAlgorithm
  • Object
show all
Defined in:
lib/auth0/mixins/validation.rb

Overview

Represents the HS256 algorithm, which rely on shared secrets.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(secret) ⇒ HS256

Returns a new instance of HS256.


241
242
243
244
245
# File 'lib/auth0/mixins/validation.rb', line 241

def initialize(secret)
  raise Auth0::InvalidParameter, 'Must supply a valid secret' if secret.to_s.empty?

  @secret = secret
end

Instance Attribute Details

#secretObject

Returns the value of attribute secret


239
240
241
# File 'lib/auth0/mixins/validation.rb', line 239

def secret
  @secret
end

Class Method Details

.secret(secret) ⇒ HS256

Create a new instance passing the shared secret.

Parameters:

  • secret (string)

    The HMAC shared secret.

Returns:

  • (HS256)

    A new instance.


234
235
236
# File 'lib/auth0/mixins/validation.rb', line 234

def secret(secret)
  new secret
end

Instance Method Details

#namestring

Returns the algorithm name.

Returns:

  • (string)

    The algorithm name.


249
250
251
# File 'lib/auth0/mixins/validation.rb', line 249

def name
  'HS256'
end