Class: Identizer::Authorization

Inherits:
Struct
  • Object
show all
Defined in:
lib/identizer/authorization.rb

Overview

What an issued code/refresh token stands for: the signed-in identity plus the authorization-request parameters needed at token time (PKCE, scope, nonce).

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#access_tokenObject

Returns the value of attribute access_token

Returns:

  • (Object)

    the current value of access_token



6
7
8
# File 'lib/identizer/authorization.rb', line 6

def access_token
  @access_token
end

#client_idObject

Returns the value of attribute client_id

Returns:

  • (Object)

    the current value of client_id



6
7
8
# File 'lib/identizer/authorization.rb', line 6

def client_id
  @client_id
end

#code_challengeObject

Returns the value of attribute code_challenge

Returns:

  • (Object)

    the current value of code_challenge



6
7
8
# File 'lib/identizer/authorization.rb', line 6

def code_challenge
  @code_challenge
end

#code_challenge_methodObject

Returns the value of attribute code_challenge_method

Returns:

  • (Object)

    the current value of code_challenge_method



6
7
8
# File 'lib/identizer/authorization.rb', line 6

def code_challenge_method
  @code_challenge_method
end

#identityObject

Returns the value of attribute identity

Returns:

  • (Object)

    the current value of identity



6
7
8
# File 'lib/identizer/authorization.rb', line 6

def identity
  @identity
end

#nonceObject

Returns the value of attribute nonce

Returns:

  • (Object)

    the current value of nonce



6
7
8
# File 'lib/identizer/authorization.rb', line 6

def nonce
  @nonce
end

#refresh_tokenObject

Returns the value of attribute refresh_token

Returns:

  • (Object)

    the current value of refresh_token



6
7
8
# File 'lib/identizer/authorization.rb', line 6

def refresh_token
  @refresh_token
end

#scopeObject

Returns the value of attribute scope

Returns:

  • (Object)

    the current value of scope



6
7
8
# File 'lib/identizer/authorization.rb', line 6

def scope
  @scope
end

Instance Method Details

#pkce_valid?(verifier) ⇒ Boolean

RFC 7636 PKCE check. No challenge issued -> nothing to verify.

Returns:

  • (Boolean)


9
10
11
12
13
14
15
16
17
18
19
# File 'lib/identizer/authorization.rb', line 9

def pkce_valid?(verifier)
  return true if code_challenge.to_s.empty?

  case code_challenge_method
  when "S256"
    digest = Digest::SHA256.digest(verifier.to_s)
    Base64.urlsafe_encode64(digest, padding: false) == code_challenge
  else # "plain" (or unspecified)
    verifier.to_s == code_challenge
  end
end