start france connect
This commit is contained in:
parent
7f91778027
commit
40d5802d4a
10 changed files with 119 additions and 4 deletions
22
app/controllers/fc_controller.rb
Normal file
22
app/controllers/fc_controller.rb
Normal file
|
@ -0,0 +1,22 @@
|
|||
class FcController < ApplicationController
|
||||
def index
|
||||
|
||||
client = OpenIDConnect::Client.new(
|
||||
identifier: FRANCE_CONNECT.identifier,
|
||||
secret: FRANCE_CONNECT.secret,
|
||||
redirect_uri: 'http://localhost:3000',
|
||||
authorization_endpoint: 'https://fce.integ01.dev-franceconnect.fr/api/v1/authorize',
|
||||
token_endpoint: 'https://fce.integ01.dev-franceconnect.fr/api/v1/token',
|
||||
userinfo_endpoint: 'https://fce.integ01.dev-franceconnect.fr/api/v1/userinfo'
|
||||
)
|
||||
|
||||
session[:state] = SecureRandom.hex(16)
|
||||
session[:nonce] = SecureRandom.hex(16)
|
||||
authorization_uri = client.authorization_uri(
|
||||
state: session[:state],
|
||||
nonce: session[:nonce]
|
||||
)
|
||||
redirect_to authorization_uri
|
||||
|
||||
end
|
||||
end
|
31
app/controllers/test_open_id_controller.rb
Normal file
31
app/controllers/test_open_id_controller.rb
Normal file
|
@ -0,0 +1,31 @@
|
|||
class TestOpenIdController < ApplicationController
|
||||
def show
|
||||
|
||||
|
||||
client = OpenIDConnect::Client.new(
|
||||
identifier: FRANCE_CONNECT.identifier,
|
||||
secret: FRANCE_CONNECT.secret,
|
||||
redirect_uri: 'http://localhost:3000',
|
||||
authorization_endpoint: 'https://fce.integ01.dev-franceconnect.fr/api/v1/authorize',
|
||||
token_endpoint: 'https://fce.integ01.dev-franceconnect.fr/api/v1/token',
|
||||
userinfo_endpoint: 'https://fce.integ01.dev-franceconnect.fr/api/v1/userinfo'
|
||||
)
|
||||
|
||||
|
||||
client.authorization_code = params[:code]
|
||||
begin
|
||||
access_token = client.access_token!(client_auth_method: :secret)
|
||||
|
||||
id_token = OpenIDConnect::ResponseObject::IdToken.decode access_token.id_token, FRANCE_CONNECT.secret
|
||||
|
||||
puts id_token
|
||||
userinfo = access_token.userinfo!
|
||||
puts userinfo
|
||||
rescue Exception => e
|
||||
|
||||
puts e.message
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
|
@ -49,11 +49,11 @@ class Dossier < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def next_step! role, action
|
||||
unless ['propose', 'reply', 'update', 'comment', 'confirme', 'depose', 'process'].include?(action)
|
||||
unless %w(propose reply update comment confirme depose process).include?(action)
|
||||
fail 'action is not valid'
|
||||
end
|
||||
|
||||
unless ['user', 'gestionnaire'].include?(role)
|
||||
unless %w(user gestionnaire).include?(role)
|
||||
fail 'role is not valid'
|
||||
end
|
||||
|
||||
|
|
1
app/views/test_open_id/show.html.haml
Normal file
1
app/views/test_open_id/show.html.haml
Normal file
|
@ -0,0 +1 @@
|
|||
%h1 coucou
|
Loading…
Add table
Add a link
Reference in a new issue