FC: move FC constants under particulier namespace
This commit is contained in:
parent
06d9c4356e
commit
0d46f92795
5 changed files with 24 additions and 21 deletions
|
@ -50,7 +50,7 @@ class Users::SessionsController < Sessions::SessionsController
|
|||
|
||||
case connected_with_france_connect
|
||||
when 'particulier'
|
||||
redirect_to FRANCE_CONNECT.particulier_logout_endpoint
|
||||
redirect_to FRANCE_CONNECT.particulier.logout_endpoint
|
||||
return
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,15 +1,13 @@
|
|||
class FranceConnectParticulierClient < OpenIDConnect::Client
|
||||
def initialize(code = nil)
|
||||
super(
|
||||
identifier: FRANCE_CONNECT.particulier_identifier,
|
||||
secret: FRANCE_CONNECT.particulier_secret,
|
||||
|
||||
redirect_uri: FRANCE_CONNECT.particulier_redirect_uri,
|
||||
|
||||
authorization_endpoint: FRANCE_CONNECT.particulier_authorization_endpoint,
|
||||
token_endpoint: FRANCE_CONNECT.particulier_token_endpoint,
|
||||
userinfo_endpoint: FRANCE_CONNECT.particulier_userinfo_endpoint,
|
||||
logout_endpoint: FRANCE_CONNECT.particulier_logout_endpoint
|
||||
identifier: FRANCE_CONNECT.particulier.identifier,
|
||||
secret: FRANCE_CONNECT.particulier.secret,
|
||||
redirect_uri: FRANCE_CONNECT.particulier.redirect_uri,
|
||||
authorization_endpoint: FRANCE_CONNECT.particulier.authorization_endpoint,
|
||||
token_endpoint: FRANCE_CONNECT.particulier.token_endpoint,
|
||||
userinfo_endpoint: FRANCE_CONNECT.particulier.userinfo_endpoint,
|
||||
logout_endpoint: FRANCE_CONNECT.particulier.logout_endpoint
|
||||
)
|
||||
|
||||
if code.present?
|
||||
|
|
|
@ -11,6 +11,6 @@ class FranceConnectSaltService
|
|||
end
|
||||
|
||||
def salt
|
||||
Digest::MD5.hexdigest(model.france_connect_particulier_id + model.given_name + model.family_name + FRANCE_CONNECT.particulier_secret + DateTime.now.to_date.to_s)
|
||||
Digest::MD5.hexdigest(model.france_connect_particulier_id + model.given_name + model.family_name + FRANCE_CONNECT.particulier.secret + DateTime.now.to_date.to_s)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,14 +1,19 @@
|
|||
FRANCE_CONNECT = if !Rails.env.test?
|
||||
file_path = "#{Rails.root}/config/france_connect.yml"
|
||||
Hashie::Mash.load(file_path)
|
||||
config_hash = YAML.safe_load(File.read(file_path))
|
||||
.reduce({}) { |acc, (key, value)| acc[key.gsub('particulier_', '')] = value, acc }
|
||||
|
||||
Hashie::Mash.new(particulier: config_hash)
|
||||
else
|
||||
Hashie::Mash.new({
|
||||
particulier_identifier: 'plop',
|
||||
particulier_secret: 'plip',
|
||||
particulier_redirect_uri: 'https://bidon.com/endpoint',
|
||||
particulier_authorization_endpoint: 'https://bidon.com/endpoint',
|
||||
particulier_token_endpoint: 'https://bidon.com/endpoint',
|
||||
particulier_userinfo_endpoint: 'https://bidon.com/endpoint',
|
||||
particulier_logout_endpoint: 'https://bidon.com/endpoint',
|
||||
particulier: {
|
||||
identifier: 'plop',
|
||||
secret: 'plip',
|
||||
redirect_uri: 'https://bidon.com/endpoint',
|
||||
authorization_endpoint: 'https://bidon.com/endpoint',
|
||||
token_endpoint: 'https://bidon.com/endpoint',
|
||||
userinfo_endpoint: 'https://bidon.com/endpoint',
|
||||
logout_endpoint: 'https://bidon.com/endpoint',
|
||||
}
|
||||
})
|
||||
end
|
||||
|
|
|
@ -118,7 +118,7 @@ describe Users::SessionsController, type: :controller do
|
|||
let(:loged_in_with_france_connect) { 'particulier' }
|
||||
|
||||
it 'redirect to france connect logout page' do
|
||||
expect(response).to redirect_to(FRANCE_CONNECT.particulier_logout_endpoint)
|
||||
expect(response).to redirect_to(FRANCE_CONNECT.particulier.logout_endpoint)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -161,7 +161,7 @@ describe Users::SessionsController, type: :controller do
|
|||
user.update_attributes(loged_in_with_france_connect: 'particulier')
|
||||
sign_in user
|
||||
delete :destroy
|
||||
expect(@response.headers["Location"]).to eq(FRANCE_CONNECT.particulier_logout_endpoint)
|
||||
expect(@response.headers["Location"]).to eq(FRANCE_CONNECT.particulier.logout_endpoint)
|
||||
end
|
||||
|
||||
context "when associated administrateur" do
|
||||
|
|
Loading…
Reference in a new issue