start france connect

This commit is contained in:
Tanguy PATTE 2015-10-05 16:42:29 +02:00
parent 7f91778027
commit 40d5802d4a
10 changed files with 119 additions and 4 deletions

View 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

View 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

View file

@ -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

View file

@ -0,0 +1 @@
%h1 coucou