Class: IesAuth::Token

Inherits:
Object
  • Object
show all
Defined in:
lib/ies_auth/model/token.rb

Overview

Usage example = Token.new example.build(message)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Token

Returns a new instance of Token.



9
10
11
12
# File 'lib/ies_auth/model/token.rb', line 9

def initialize(data)
  @data = data
  @session, @enc = JWT.decode(data, nil, false, { algorithm: 'RS512' })
end

Instance Attribute Details

#clientObject



18
19
20
# File 'lib/ies_auth/model/token.rb', line 18

def client
  @client ||= "ies_auth"
end

#dataObject (readonly)

Returns the value of attribute data.



7
8
9
# File 'lib/ies_auth/model/token.rb', line 7

def data
  @data
end

#encObject (readonly)

Returns the value of attribute enc.



7
8
9
# File 'lib/ies_auth/model/token.rb', line 7

def enc
  @enc
end

#sessionObject (readonly)

Returns the value of attribute session.



7
8
9
# File 'lib/ies_auth/model/token.rb', line 7

def session
  @session
end

Instance Method Details

#algorithmObject



14
15
16
# File 'lib/ies_auth/model/token.rb', line 14

def algorithm
  enc["alg"]
end

#expirationObject



22
23
24
# File 'lib/ies_auth/model/token.rb', line 22

def expiration
  Time.at(session["exp"])
end

#hccObject



26
27
28
# File 'lib/ies_auth/model/token.rb', line 26

def hcc
  session["hcc"]
end

#issued_atObject



30
31
32
# File 'lib/ies_auth/model/token.rb', line 30

def issued_at
  Time.at(session["iat"])
end

#kidObject



34
35
36
# File 'lib/ies_auth/model/token.rb', line 34

def kid
  enc["kid"]
end

#session_idObject



38
39
40
# File 'lib/ies_auth/model/token.rb', line 38

def session_id
  session["sessid"]
end

#subObject



42
43
44
# File 'lib/ies_auth/model/token.rb', line 42

def sub
  session["sub"]
end

#typeObject



46
47
48
# File 'lib/ies_auth/model/token.rb', line 46

def type
  session["type"]
end

#user_idObject



50
51
52
# File 'lib/ies_auth/model/token.rb', line 50

def user_id
  sub
end