Class: YesWeHack::Auth
- Inherits:
-
Object
- Object
- YesWeHack::Auth
- Defined in:
- lib/scopes_extractor/platforms/yeswehack/jwt.rb
Overview
YesWeHack Auth Class
Class Method Summary collapse
Class Method Details
.extract_totp_token ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/scopes_extractor/platforms/yeswehack/jwt.rb', line 19 def self.extract_totp_token data = { email: ENV.fetch('YWH_EMAIL', nil), password: ENV.fetch('YWH_PASSWORD', nil) }.to_json response = HttpClient.post('https://api.yeswehack.com/login', data) return unless response&.code == 200 JSON.parse(response.body)['totp_token'] end |
.jwt ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/scopes_extractor/platforms/yeswehack/jwt.rb', line 6 def self.jwt totp_token = extract_totp_token return unless totp_token response = send_totp(totp_token) return unless response jwt = JSON.parse(response.body)['token'] return unless jwt jwt end |
.send_totp(totp_token) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/scopes_extractor/platforms/yeswehack/jwt.rb', line 27 def self.send_totp(totp_token) data = { token: totp_token, code: ROTP::TOTP.new(ENV['YWH_OTP']).now }.to_json response = HttpClient.post('https://api.yeswehack.com/account/totp', data) return unless response.code == 200 response end |