Module: PhraseApp::Auth
- Defined in:
- lib/auth.rb
Defined Under Namespace
Classes: AuthHandler
Class Method Summary collapse
- .authenticate(req) ⇒ Object
- .authH ⇒ Object
- .debug ⇒ Object
- .host ⇒ Object
- .register_auth_handler(a) ⇒ Object
- .skip_ssl_verification ⇒ Object
Class Method Details
.authenticate(req) ⇒ Object
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/auth.rb', line 89 def self.authenticate(req) if authH == nil raise("no auth handler registered") end if err = authH.load_config return err end if err = authH.validate return err end if authH.token && authH.token != "" req["Authorization"] = "token #{authH.token}" elsif authH.username && authH.username != "" req.basic_auth(authH.username, authH.password) if authH.tfa or authH.tfa_token # TFA only required for username+password based login. raise "Multi-Factor Token required in config but not provided." unless authH.tfa_token req["X-PhraseApp-OTP"] = auth.tfa_token end else raise "No authentication present" end return nil end |
.authH ⇒ Object
57 58 59 |
# File 'lib/auth.rb', line 57 def self.authH defined?(@@authH) && @@authH end |
.debug ⇒ Object
81 82 83 84 85 86 87 |
# File 'lib/auth.rb', line 81 def self.debug if authH.debug && authH.debug != "" return authH.debug else return false end end |
.host ⇒ Object
65 66 67 68 69 70 71 |
# File 'lib/auth.rb', line 65 def self.host if authH.host && authH.host != "" return authH.host else return PhraseApp::URL end end |
.register_auth_handler(a) ⇒ Object
61 62 63 |
# File 'lib/auth.rb', line 61 def self.register_auth_handler(a) @@authH = a end |
.skip_ssl_verification ⇒ Object
73 74 75 76 77 78 79 |
# File 'lib/auth.rb', line 73 def self.skip_ssl_verification if authH.skip_ssl_verification && authH.skip_ssl_verification return true else return false end end |