Class: OmniAuth::Strategies::Twinfield
- Inherits:
-
OAuth2
- Object
- OAuth2
- OmniAuth::Strategies::Twinfield
- Defined in:
- lib/omniauth/strategies/twinfield.rb
Overview
Twinfield OmniAuth Strategy; follows OmniAuth::Strategies::OAuth2’s base strategy
Defined Under Namespace
Classes: InvalidToken
Class Method Summary collapse
-
.validate_token(token) ⇒ Object
Can’t do a JWT token validation in absence of verification keys.
Instance Method Summary collapse
- #build_access_token ⇒ Object
- #info ⇒ Object
- #raw_info ⇒ Object
- #refresh_token ⇒ Object
- #request_phase ⇒ Object
- #uid ⇒ Object
Class Method Details
.validate_token(token) ⇒ Object
Can’t do a JWT token validation in absence of verification keys
82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/omniauth/strategies/twinfield.rb', line 82 def validate_token(token) uri = URI.parse("https://login.twinfield.com/auth/authentication/connect/accesstokenvalidation?token=#{token}") http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true request = Net::HTTP::Get.new(uri) http_response = http.request(request) response = JSON.parse(http_response.body) raise InvalidToken, response["Message"] if response["Message"] response end |
Instance Method Details
#build_access_token ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/omniauth/strategies/twinfield.rb', line 57 def build_access_token verifier = request.params["code"] data = { headers: , code: verifier, redirect_uri: callback_url.split(/\?/)[0], grant_type: "authorization_code" } client.auth_code.get_token(verifier, data) end |
#info ⇒ Object
45 46 47 |
# File 'lib/omniauth/strategies/twinfield.rb', line 45 def info raw_info end |
#raw_info ⇒ Object
53 54 55 |
# File 'lib/omniauth/strategies/twinfield.rb', line 53 def raw_info @raw_info ||= self.class.validate_token(access_token.token) end |
#refresh_token ⇒ Object
49 50 51 |
# File 'lib/omniauth/strategies/twinfield.rb', line 49 def refresh_token access_token.to_hash[:refresh_token] end |
#request_phase ⇒ Object
37 38 39 |
# File 'lib/omniauth/strategies/twinfield.rb', line 37 def request_phase redirect client.auth_code.({ redirect_uri: callback_url }.merge()) end |
#uid ⇒ Object
41 42 43 |
# File 'lib/omniauth/strategies/twinfield.rb', line 41 def uid raw_info["sub"] end |