Class: Legion::Extensions::MicrosoftTeams::Actor::AuthValidator

Inherits:
Actors::Once
  • Object
show all
Defined in:
lib/legion/extensions/microsoft_teams/actors/auth_validator.rb

Overview

rubocop:disable Legion/Extension/SelfContainedActorRunnerClass

Instance Method Summary collapse

Instance Method Details

#check_subtask?Boolean

Returns:

  • (Boolean)


9
# File 'lib/legion/extensions/microsoft_teams/actors/auth_validator.rb', line 9

def check_subtask?  = false

#delayObject



12
13
14
# File 'lib/legion/extensions/microsoft_teams/actors/auth_validator.rb', line 12

def delay
  90.0
end

#enabled?Boolean

Returns:

  • (Boolean)


16
17
18
19
20
21
# File 'lib/legion/extensions/microsoft_teams/actors/auth_validator.rb', line 16

def enabled?
  defined?(Legion::Extensions::MicrosoftTeams::Helpers::TokenCache)
rescue StandardError => e
  log.debug("AuthValidator#enabled?: #{e.message}")
  false
end

#generate_task?Boolean

Returns:

  • (Boolean)


10
# File 'lib/legion/extensions/microsoft_teams/actors/auth_validator.rb', line 10

def generate_task?  = false

#manualObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/legion/extensions/microsoft_teams/actors/auth_validator.rb', line 27

def manual
  log.info('AuthValidator starting')
  cache = token_cache
  log.debug("Token loaded: authenticated?=#{cache.authenticated?}")

  if cache.authenticated?
    token = cache.cached_delegated_token
    if token
      log.info('Teams delegated auth restored (token valid)')
    elsif cache.previously_authenticated? || auto_authenticate?
      log.info('Token loaded but expired, attempting browser re-auth')
      attempt_browser_reauth(cache)
    else
      log.debug('Token loaded but expired, no re-auth configured')
    end
  elsif cache.previously_authenticated?
    log.warn('Token file found but could not load, attempting re-authentication')
    attempt_browser_reauth(cache)
  elsif auto_authenticate?
    log.info('auto_authenticate enabled, opening browser for initial authentication...')
    attempt_browser_reauth(cache)
  else
    log.debug('No Teams delegated auth configured, skipping')
  end
  log.info('AuthValidator complete')
rescue StandardError => e
  log.error("AuthValidator: #{e.message}")
end

#token_cacheObject



23
24
25
# File 'lib/legion/extensions/microsoft_teams/actors/auth_validator.rb', line 23

def token_cache
  Legion::Extensions::MicrosoftTeams::Helpers::TokenCache.instance
end

#use_runner?Boolean

Returns:

  • (Boolean)


8
# File 'lib/legion/extensions/microsoft_teams/actors/auth_validator.rb', line 8

def use_runner?     = false