Class: Himari::SessionData

Inherits:
Object
  • Object
show all
Includes:
TokenString
Defined in:
lib/himari/session_data.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from TokenString

#expiry, #format, #handle, included, #magic_header, #secret, #secret_hash, #verify!, #verify_expiry!, #verify_secret!

Constructor Details

#initialize(claims: {}, user_data: {}, handle:, secret: nil, secret_hash: nil, expiry: nil) ⇒ SessionData

Returns a new instance of SessionData.



7
8
9
10
11
12
13
14
15
# File 'lib/himari/session_data.rb', line 7

def initialize(claims: {}, user_data: {}, handle:, secret: nil, secret_hash: nil, expiry: nil)
  @claims = claims
  @user_data = user_data

  @handle = handle
  @secret = secret
  @secret_hash = secret_hash
  @expiry = expiry
end

Instance Attribute Details

#claimsObject (readonly)

Returns the value of attribute claims.



25
26
27
# File 'lib/himari/session_data.rb', line 25

def claims
  @claims
end

#user_dataObject (readonly)

Returns the value of attribute user_data.



25
26
27
# File 'lib/himari/session_data.rb', line 25

def user_data
  @user_data
end

Class Method Details

.default_lifetimeObject



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

def self.default_lifetime
  3600
end

.magic_headerObject



17
18
19
# File 'lib/himari/session_data.rb', line 17

def self.magic_header
  'hmas'
end

Instance Method Details

#as_jsonObject



35
36
37
38
39
40
41
42
43
44
# File 'lib/himari/session_data.rb', line 35

def as_json
  {
    handle: handle,
    secret_hash: secret_hash,
    expiry: expiry,

    claims: claims,
    user_data: user_data,
  }
end

#as_logObject



27
28
29
30
31
32
33
# File 'lib/himari/session_data.rb', line 27

def as_log
  {
    handle: handle,
    claims: claims,
    expiry: expiry,
  }
end