Sha256: 7d6f6b824c86a7e4eec575e82e4d6d58ac1e5034ac4106a60e1c4311acb2ac8a

Contents?: true

Size: 1.48 KB

Versions: 82

Compression:

Stored size: 1.48 KB

Contents

require 'openid_connect'

module ForestLiana
  class OidcClientManager
    def self.get_client
      begin
        configuration = ForestLiana::OidcConfigurationRetriever.retrieve()
        if ForestLiana.forest_client_id.nil?
          client_data = Rails.cache.read("#{ForestLiana.env_secret}-client-data") || nil
          if client_data.nil?
            client_credentials = ForestLiana::OidcDynamicClientRegistrator.register({
              token_endpoint_auth_method: 'none',
              registration_endpoint: configuration['registration_endpoint']
            })
            client_data = { :client_id => client_credentials['client_id'], :issuer => configuration['issuer'], :redirect_uri => client_credentials['redirect_uris'][0] }
            Rails.cache.write("#{ForestLiana.env_secret}-client-data", client_data)
          end
        else
          client_data = { :client_id => ForestLiana.forest_client_id, :issuer => configuration['issuer'], :redirect_uri => File.join(ForestLiana.application_url, "/forest/authentication/callback").to_s }
        end

        OpenIDConnect::Client.new(
          identifier: client_data[:client_id],
          redirect_uri: client_data[:redirect_uri],
          host: "#{client_data[:issuer].sub(/^https?\:\/\/(www.)?/,'')}",
          authorization_endpoint: '/oidc/auth',
          token_endpoint: '/oidc/token',
        )
      rescue => error
        Rails.cache.delete("#{ForestLiana.env_secret}-client-data")
        raise error
      end
    end
  end
end

Version data entries

82 entries across 82 versions & 1 rubygems

Version Path
forest_liana-9.7.0 app/services/forest_liana/oidc_client_manager.rb
forest_liana-9.6.4 app/services/forest_liana/oidc_client_manager.rb
forest_liana-9.6.3 app/services/forest_liana/oidc_client_manager.rb
forest_liana-9.6.0 app/services/forest_liana/oidc_client_manager.rb
forest_liana-9.5.7 app/services/forest_liana/oidc_client_manager.rb
forest_liana-9.5.6 app/services/forest_liana/oidc_client_manager.rb
forest_liana-9.5.5 app/services/forest_liana/oidc_client_manager.rb
forest_liana-9.5.4 app/services/forest_liana/oidc_client_manager.rb
forest_liana-9.5.3 app/services/forest_liana/oidc_client_manager.rb
forest_liana-9.5.2 app/services/forest_liana/oidc_client_manager.rb
forest_liana-9.5.1 app/services/forest_liana/oidc_client_manager.rb
forest_liana-9.5.0 app/services/forest_liana/oidc_client_manager.rb
forest_liana-9.4.3 app/services/forest_liana/oidc_client_manager.rb
forest_liana-9.4.2 app/services/forest_liana/oidc_client_manager.rb
forest_liana-9.4.1 app/services/forest_liana/oidc_client_manager.rb
forest_liana-9.4.0 app/services/forest_liana/oidc_client_manager.rb
forest_liana-8.3.3 app/services/forest_liana/oidc_client_manager.rb
forest_liana-9.3.16 app/services/forest_liana/oidc_client_manager.rb
forest_liana-9.3.15 app/services/forest_liana/oidc_client_manager.rb
forest_liana-9.3.14 app/services/forest_liana/oidc_client_manager.rb