Class: OmniAuth::Strategies::LightspeedOauth2
- Inherits:
-
OAuth2
- Object
- OAuth2
- OmniAuth::Strategies::LightspeedOauth2
- Defined in:
- lib/omniauth/strategies/lightspeed_oauth2.rb
Overview
OmniAuth strategy for Lightspeed Restaurant (K-Series) OAuth2.
Lightspeed uses OpenID Connect (Keycloak) with standard OAuth2 Authorization Code Grant. Access tokens expire; use refresh tokens to obtain new pairs.
Demo/Trial: auth.lsk-demo.app, api.trial.lsk.lightspeed.app Production: auth.lsk-prod.app, api.lsk.lightspeed.app
Constant Summary collapse
- ENVIRONMENTS =
{ trial: { site: 'https://api.trial.lsk.lightspeed.app', authorize_url: 'https://auth.lsk-demo.app/realms/k-series/protocol/openid-connect/auth', token_url: 'https://auth.lsk-demo.app/realms/k-series/protocol/openid-connect/token' }, production: { site: 'https://api.lsk.lightspeed.app', authorize_url: 'https://auth.lsk-prod.app/realms/k-series/protocol/openid-connect/auth', token_url: 'https://auth.lsk-prod.app/realms/k-series/protocol/openid-connect/token' } }.freeze
Instance Method Summary collapse
-
#build_access_token ⇒ Object
Override to strip query params from callback_url for redirect_uri matching.
- #raw_info ⇒ Object
- #setup_phase ⇒ Object
Instance Method Details
#build_access_token ⇒ Object
Override to strip query params from callback_url for redirect_uri matching.
83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/omniauth/strategies/lightspeed_oauth2.rb', line 83 def build_access_token redirect_uri = callback_url.sub(/\?.*/, '') log(:info, "Token exchange — site: #{client.site}, redirect_uri: #{redirect_uri}") verifier = request.params['code'] client.auth_code.get_token( verifier, { redirect_uri: redirect_uri }.merge(token_params.to_hash(symbolize_keys: true)), deep_symbolize(.auth_token_params) ) rescue ::OAuth2::Error => e log(:error, "Token exchange FAILED: status=#{e.response&.status} body=#{e.response&.body}") raise end |
#raw_info ⇒ Object
78 79 80 |
# File 'lib/omniauth/strategies/lightspeed_oauth2.rb', line 78 def raw_info @raw_info ||= fetch_business_info end |
#setup_phase ⇒ Object
53 54 55 56 57 58 |
# File 'lib/omniauth/strategies/lightspeed_oauth2.rb', line 53 def setup_phase env = [:environment]&.to_sym || :trial urls = ENVIRONMENTS.fetch(env, ENVIRONMENTS[:trial]) ..merge!(urls) super end |