Class: ForestLiana::Authentication
- Inherits:
-
Object
- Object
- ForestLiana::Authentication
- Defined in:
- app/services/forest_liana/authentication.rb
Instance Method Summary collapse
- #start_authentication(redirect_url, state) ⇒ Object
- #verify_code_and_generate_token(redirect_url, params) ⇒ Object
Instance Method Details
#start_authentication(redirect_url, state) ⇒ Object
3 4 5 6 7 8 9 10 11 12 |
# File 'app/services/forest_liana/authentication.rb', line 3 def start_authentication(redirect_url, state) client = ForestLiana::OidcClientManager.get_client_for_callback_url(redirect_url) = client.({ scope: 'openid email profile', state: state.to_s, }) { 'authorization_url' => } end |
#verify_code_and_generate_token(redirect_url, params) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/services/forest_liana/authentication.rb', line 14 def verify_code_and_generate_token(redirect_url, params) client = ForestLiana::OidcClientManager.get_client_for_callback_url(redirect_url) rendering_id = parse_state(params['state']) client. = params['code'] if Rails.env.development? || Rails.env.test? OpenIDConnect.http_config do |config| config.ssl_config.verify_mode = OpenSSL::SSL::VERIFY_NONE end end access_token_instance = client.access_token! 'none' user = ForestLiana::AuthorizationGetter.authenticate( rendering_id, { :forest_token => access_token_instance.instance_variable_get(:@access_token) }, ) return ForestLiana::Token.create_token(user, rendering_id) end |