1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-12-01 12:24:28 +01:00
fab-manager/lib/omni_auth/strategies/sso_openid_connect_provider.rb

35 lines
922 B
Ruby
Raw Normal View History

# frozen_string_literal: true
require 'omniauth_openid_connect'
require_relative '../data_mapping/mapper'
2023-03-29 18:01:16 +02:00
# Authentication strategy provided trough OpenID Connect
class OmniAuth::Strategies::SsoOpenidConnectProvider < OmniAuth::Strategies::OpenIDConnect
include OmniAuth::DataMapping::Mapper
2023-03-29 18:01:16 +02:00
def self.active_provider
active_provider = Rails.configuration.auth_provider
if active_provider.providable_type != 'OpenIdConnectProvider'
raise "Trying to instantiate the wrong provider: Expected OpenIdConnectProvider, received #{active_provider.providable_type}"
end
2023-03-29 18:01:16 +02:00
active_provider
end
2023-03-29 18:01:16 +02:00
# Strategy name.
option :name, active_provider.strategy_name
2023-03-29 18:01:16 +02:00
info do
{
mapping: parsed_info
}
end
def parsed_info
mapped_info(
OmniAuth::Strategies::SsoOpenidConnectProvider.active_provider.auth_provider_mappings,
user_info: user_info.raw_attributes
)
end
end