Class: CommandTower::Auth::AuthContext

Inherits:
Data
  • Object
show all
Defined in:
app/auth/command_tower/auth/auth_context.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user:, token_expires_at:, token_source:, roles:, principal_type:, generated_token: nil, actor_user: nil, impersonation_session_id: nil) ⇒ AuthContext

Returns a new instance of AuthContext.



15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/auth/command_tower/auth/auth_context.rb', line 15

def initialize(user:, token_expires_at:, token_source:, roles:, principal_type:, generated_token: nil, actor_user: nil, impersonation_session_id: nil)
  super(
    user:,
    token_expires_at:,
    token_source:,
    roles:,
    principal_type:,
    generated_token:,
    actor_user: actor_user || user,
    impersonation_session_id:
  )
end

Instance Attribute Details

#actor_userObject (readonly)

Returns the value of attribute actor_user

Returns:

  • (Object)

    the current value of actor_user



5
6
7
# File 'app/auth/command_tower/auth/auth_context.rb', line 5

def actor_user
  @actor_user
end

#generated_tokenObject (readonly)

Returns the value of attribute generated_token

Returns:

  • (Object)

    the current value of generated_token



5
6
7
# File 'app/auth/command_tower/auth/auth_context.rb', line 5

def generated_token
  @generated_token
end

#impersonation_session_idObject (readonly)

Returns the value of attribute impersonation_session_id

Returns:

  • (Object)

    the current value of impersonation_session_id



5
6
7
# File 'app/auth/command_tower/auth/auth_context.rb', line 5

def impersonation_session_id
  @impersonation_session_id
end

#principal_typeObject (readonly)

Returns the value of attribute principal_type

Returns:

  • (Object)

    the current value of principal_type



5
6
7
# File 'app/auth/command_tower/auth/auth_context.rb', line 5

def principal_type
  @principal_type
end

#rolesObject (readonly)

Returns the value of attribute roles

Returns:

  • (Object)

    the current value of roles



5
6
7
# File 'app/auth/command_tower/auth/auth_context.rb', line 5

def roles
  @roles
end

#token_expires_atObject (readonly)

Returns the value of attribute token_expires_at

Returns:

  • (Object)

    the current value of token_expires_at



5
6
7
# File 'app/auth/command_tower/auth/auth_context.rb', line 5

def token_expires_at
  @token_expires_at
end

#token_sourceObject (readonly)

Returns the value of attribute token_source

Returns:

  • (Object)

    the current value of token_source



5
6
7
# File 'app/auth/command_tower/auth/auth_context.rb', line 5

def token_source
  @token_source
end

#userObject (readonly)

Returns the value of attribute user

Returns:

  • (Object)

    the current value of user



5
6
7
# File 'app/auth/command_tower/auth/auth_context.rb', line 5

def user
  @user
end

Class Method Details

.from_authenticate_session_result(data:, metadata:) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
# File 'app/auth/command_tower/auth/auth_context.rb', line 28

def self.from_authenticate_session_result(data:, metadata:)
  new(
    user: data[:user],
    token_expires_at: data[:token_expires_at],
    token_source: [:token_source],
    roles: data[:user].roles,
    principal_type: :user,
    generated_token: data[:generated_token],
    actor_user: data[:actor_user] || data[:user],
    impersonation_session_id: data[:impersonation_session_id]
  )
end