2019-12-11 00:24:53 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module OmniAuth
|
|
|
|
module Strategies
|
2022-10-26 21:18:31 +08:00
|
|
|
class CustomAzureActiveDirectory < AzureActivedirectoryV2
|
2019-12-11 00:24:53 +08:00
|
|
|
include OmniAuth::Strategy
|
|
|
|
|
2022-10-26 21:18:31 +08:00
|
|
|
option :name, 'customazureactivedirectory'
|
2019-12-11 00:24:53 +08:00
|
|
|
|
2022-10-26 21:18:31 +08:00
|
|
|
def raw_info
|
|
|
|
if @raw_info.nil?
|
|
|
|
id_token_data = ::JWT.decode(access_token.params['id_token'], nil, false).first rescue {}
|
|
|
|
auth_token_data = ::JWT.decode(access_token.token, nil, false).first rescue {}
|
|
|
|
@raw_info = auth_token_data.merge(id_token_data)
|
|
|
|
end
|
2019-12-11 00:24:53 +08:00
|
|
|
|
2022-10-26 21:18:31 +08:00
|
|
|
@raw_info
|
2019-12-11 00:24:53 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
OmniAuth.config.add_camelization 'custom_azure_activedirectory', 'CustomAzureActiveDirectory'
|