Class: JwtRest::AuthHeader

Inherits:
Object
  • Object
show all
Defined in:
lib/jwt_rest/auth_header.rb

Instance Method Summary collapse

Constructor Details

#initialize(chunk = "") ⇒ AuthHeader

Returns a new instance of AuthHeader.



3
4
5
6
# File 'lib/jwt_rest/auth_header.rb', line 3

def initialize(chunk = "")
  @type, @value = chunk.split(" ")
  @type = @type&.downcase
end

Instance Method Details

#is_basic?Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/jwt_rest/auth_header.rb', line 8

def is_basic?
  type == "basic"
end

#is_token?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/jwt_rest/auth_header.rb', line 12

def is_token?
  type == "bearer"
end

#tokenObject



16
17
18
19
# File 'lib/jwt_rest/auth_header.rb', line 16

def token
  return JwtRest::Tokens::Basic.new(token: value).load_token if is_basic?
  return JwtRest::Tokens::Jwt.new(token: value).load_token if is_token?
end