start france connect
This commit is contained in:
parent
7f91778027
commit
40d5802d4a
10 changed files with 119 additions and 4 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -28,3 +28,4 @@ bin/*
|
|||
config/initializers/token.rb
|
||||
doc/*.svg
|
||||
rubocop.html
|
||||
config/france_connect.yml
|
3
Gemfile
3
Gemfile
|
@ -42,6 +42,7 @@ gem 'draper'
|
|||
|
||||
#Gestion des comptes utilisateurs
|
||||
gem 'devise'
|
||||
gem 'openid_connect'
|
||||
gem 'rest-client'
|
||||
|
||||
gem 'carrierwave'
|
||||
|
@ -61,6 +62,8 @@ gem 'logstasher'
|
|||
|
||||
gem "font-awesome-rails"
|
||||
|
||||
gem 'hashie'
|
||||
|
||||
group :test do
|
||||
gem 'capybara'
|
||||
gem 'factory_girl'
|
||||
|
|
47
Gemfile.lock
47
Gemfile.lock
|
@ -49,10 +49,12 @@ GEM
|
|||
ast (2.0.0)
|
||||
astrolabe (1.3.0)
|
||||
parser (>= 2.2.0.pre.3, < 3.0)
|
||||
attr_required (1.0.0)
|
||||
autoprefixer-rails (5.2.1)
|
||||
execjs
|
||||
json
|
||||
bcrypt (3.1.10)
|
||||
bindata (2.1.0)
|
||||
binding_of_caller (0.7.2)
|
||||
debug_inspector (>= 0.0.1)
|
||||
bootstrap-datepicker-rails (1.4.0)
|
||||
|
@ -126,6 +128,7 @@ GEM
|
|||
haml (>= 4.0.6, < 5.0)
|
||||
html2haml (>= 1.0.1)
|
||||
railties (>= 4.0.1)
|
||||
hashie (3.4.1)
|
||||
html2haml (2.0.0)
|
||||
erubis (~> 2.7.0)
|
||||
haml (~> 4.0.0)
|
||||
|
@ -133,6 +136,7 @@ GEM
|
|||
ruby_parser (~> 3.5)
|
||||
http-cookie (1.0.2)
|
||||
domain_name (~> 0.5)
|
||||
httpclient (2.6.0.1)
|
||||
i18n (0.7.0)
|
||||
jbuilder (2.3.1)
|
||||
activesupport (>= 3.0.0, < 5)
|
||||
|
@ -142,6 +146,12 @@ GEM
|
|||
railties (>= 4.2.0)
|
||||
thor (>= 0.14, < 2.0)
|
||||
json (1.8.3)
|
||||
json-jwt (1.5.1)
|
||||
activesupport
|
||||
bindata
|
||||
multi_json (>= 1.3)
|
||||
securecompare
|
||||
url_safe_base64
|
||||
kgio (2.9.3)
|
||||
leaflet-draw-rails (0.1.0)
|
||||
leaflet-markercluster-rails (0.7.0)
|
||||
|
@ -165,6 +175,17 @@ GEM
|
|||
nokogiri (1.6.6.2)
|
||||
mini_portile (~> 0.6.0)
|
||||
open4 (1.3.4)
|
||||
openid_connect (0.9.2)
|
||||
activemodel
|
||||
attr_required (>= 1.0.0)
|
||||
json (>= 1.4.3)
|
||||
json-jwt (>= 1.5.0)
|
||||
rack-oauth2 (>= 1.2.1)
|
||||
swd (>= 1.0.0)
|
||||
tzinfo
|
||||
validate_email
|
||||
validate_url
|
||||
webfinger (>= 1.0.1)
|
||||
orm_adapter (0.5.0)
|
||||
parser (2.2.2.2)
|
||||
ast (>= 1.1, < 3.0)
|
||||
|
@ -183,6 +204,12 @@ GEM
|
|||
byebug (~> 5.0)
|
||||
pry (~> 0.10)
|
||||
rack (1.6.4)
|
||||
rack-oauth2 (1.2.1)
|
||||
activesupport (>= 2.3)
|
||||
attr_required (>= 0.0.5)
|
||||
httpclient (>= 2.4)
|
||||
multi_json (>= 1.3.6)
|
||||
rack (>= 1.1)
|
||||
rack-test (0.6.3)
|
||||
rack (>= 1.0)
|
||||
railroady (1.3.0)
|
||||
|
@ -266,6 +293,7 @@ GEM
|
|||
sdoc (0.4.1)
|
||||
json (~> 1.7, >= 1.7.7)
|
||||
rdoc (~> 4.0)
|
||||
securecompare (1.0.0)
|
||||
selenium-webdriver (2.44.0)
|
||||
childprocess (~> 0.5)
|
||||
multi_json (~> 1.0)
|
||||
|
@ -291,6 +319,12 @@ GEM
|
|||
actionpack (>= 3.0)
|
||||
activesupport (>= 3.0)
|
||||
sprockets (>= 2.8, < 4.0)
|
||||
swd (1.0.0)
|
||||
activesupport (>= 3)
|
||||
attr_required (>= 0.0.5)
|
||||
httpclient (>= 2.4)
|
||||
i18n
|
||||
json (>= 1.4.3)
|
||||
thor (0.19.1)
|
||||
thread_safe (0.3.5)
|
||||
tilt (1.4.1)
|
||||
|
@ -309,6 +343,13 @@ GEM
|
|||
kgio (~> 2.6)
|
||||
rack
|
||||
raindrops (~> 0.7)
|
||||
url_safe_base64 (0.2.2)
|
||||
validate_email (0.1.6)
|
||||
activemodel (>= 3.0)
|
||||
mail (>= 2.2.5)
|
||||
validate_url (1.0.2)
|
||||
activemodel (>= 3.0.0)
|
||||
addressable
|
||||
warden (1.2.3)
|
||||
rack (>= 1.0)
|
||||
web-console (2.2.1)
|
||||
|
@ -316,6 +357,10 @@ GEM
|
|||
binding_of_caller (>= 0.7.2)
|
||||
railties (>= 4.0)
|
||||
sprockets-rails (>= 2.0, < 4.0)
|
||||
webfinger (1.0.1)
|
||||
activesupport
|
||||
httpclient (>= 2.4)
|
||||
multi_json
|
||||
webmock (1.21.0)
|
||||
addressable (>= 2.3.6)
|
||||
crack (>= 0.3.2)
|
||||
|
@ -343,6 +388,7 @@ DEPENDENCIES
|
|||
factory_girl
|
||||
font-awesome-rails
|
||||
haml-rails
|
||||
hashie
|
||||
jbuilder (~> 2.0)
|
||||
jquery-rails
|
||||
leaflet-draw-rails
|
||||
|
@ -350,6 +396,7 @@ DEPENDENCIES
|
|||
leaflet-rails
|
||||
logstasher
|
||||
mina!
|
||||
openid_connect
|
||||
pg
|
||||
poltergeist
|
||||
pry-byebug
|
||||
|
|
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
|
2
config/initializers/france_connect.rb
Normal file
2
config/initializers/france_connect.rb
Normal file
|
@ -0,0 +1,2 @@
|
|||
file_path = "#{Rails.root}/config/france_connect.yml"
|
||||
FRANCE_CONNECT = Hashie::Mash.load(file_path)
|
5
config/initializers/open_id_connect.rb
Normal file
5
config/initializers/open_id_connect.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
OpenIDConnect.debug!
|
||||
OpenIDConnect.logger = Rails.logger
|
||||
Rack::OAuth2.logger = Rails.logger
|
||||
# Webfinger.logger = Rails.logger
|
||||
SWD.logger = Rails.logger
|
|
@ -9,8 +9,11 @@ Rails.application.routes.draw do
|
|||
}, skip: [:password, :registrations]
|
||||
|
||||
|
||||
# root 'welcome#index'
|
||||
root 'users/dossiers#index'
|
||||
|
||||
# root 'users/dossiers#index'
|
||||
root 'test_open_id#show'
|
||||
get '/fc' => 'fc#index'
|
||||
|
||||
|
||||
namespace :users do
|
||||
get 'siret' => 'siret#index'
|
||||
|
|
Loading…
Reference in a new issue