Intégration France Connect - sans les tests
This commit is contained in:
parent
40d5802d4a
commit
fd60692ade
19 changed files with 86 additions and 337 deletions
|
@ -1 +0,0 @@
|
||||||
admi_facile
|
|
|
@ -1,37 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<module type="JAVA_MODULE" version="4">
|
|
||||||
<component name="FacetManager">
|
|
||||||
<facet type="JRUBY" name="JRuby">
|
|
||||||
<configuration>
|
|
||||||
<JRUBY_FACET_CONFIG_ID NAME="JRUBY_SDK_NAME" VALUE="" />
|
|
||||||
<LOAD_PATH number="0" />
|
|
||||||
<I18N_FOLDERS number="0" />
|
|
||||||
</configuration>
|
|
||||||
<facet type="JRailsFacetType" name="JRuby on Rails">
|
|
||||||
<configuration>
|
|
||||||
<RAILS_FACET_CONFIG_ID NAME="RAILS_FACET_SUPPORT_REMOVED" VALUE="false" />
|
|
||||||
<RAILS_FACET_CONFIG_ID NAME="RAILS_TESTS_SOURCES_PATCHED" VALUE="true" />
|
|
||||||
<RAILS_FACET_CONFIG_ID NAME="RAILS_FACET_APPLICATION_ROOT" VALUE="$MODULE_DIR$" />
|
|
||||||
</configuration>
|
|
||||||
</facet>
|
|
||||||
</facet>
|
|
||||||
</component>
|
|
||||||
<component name="NewModuleRootManager" inherit-compiler-output="false">
|
|
||||||
<output url="file://$APPLICATION_HOME_DIR$/bin" />
|
|
||||||
<output-test url="file://$APPLICATION_HOME_DIR$/bin" />
|
|
||||||
<exclude-output />
|
|
||||||
<content url="file://$MODULE_DIR$">
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/spec" isTestSource="true" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/components" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/public/system" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/tmp" />
|
|
||||||
</content>
|
|
||||||
<orderEntry type="inheritedJdk" />
|
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
|
||||||
</component>
|
|
||||||
<component name="RModuleSettingsStorage">
|
|
||||||
<LOAD_PATH number="0" />
|
|
||||||
<I18N_FOLDERS number="1" string0="$MODULE_DIR$/config/locales" />
|
|
||||||
</component>
|
|
||||||
</module>
|
|
|
@ -1,13 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="ProjectCodeStyleSettingsManager">
|
|
||||||
<option name="PER_PROJECT_SETTINGS">
|
|
||||||
<value>
|
|
||||||
<XML>
|
|
||||||
<option name="XML_LEGACY_SETTINGS_IMPORTED" value="true" />
|
|
||||||
</XML>
|
|
||||||
</value>
|
|
||||||
</option>
|
|
||||||
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
|
@ -1,22 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="CompilerConfiguration">
|
|
||||||
<resourceExtensions />
|
|
||||||
<wildcardResourcePatterns>
|
|
||||||
<entry name="!?*.java" />
|
|
||||||
<entry name="!?*.form" />
|
|
||||||
<entry name="!?*.class" />
|
|
||||||
<entry name="!?*.groovy" />
|
|
||||||
<entry name="!?*.scala" />
|
|
||||||
<entry name="!?*.flex" />
|
|
||||||
<entry name="!?*.kt" />
|
|
||||||
<entry name="!?*.clj" />
|
|
||||||
<entry name="!?*.aj" />
|
|
||||||
</wildcardResourcePatterns>
|
|
||||||
<annotationProcessing>
|
|
||||||
<profile default="true" name="Default" enabled="false">
|
|
||||||
<processorPath useClasspath="true" />
|
|
||||||
</profile>
|
|
||||||
</annotationProcessing>
|
|
||||||
</component>
|
|
||||||
</project>
|
|
|
@ -1,3 +0,0 @@
|
||||||
<component name="CopyrightManager">
|
|
||||||
<settings default="" />
|
|
||||||
</component>
|
|
|
@ -1,30 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="ProjectInspectionProfilesVisibleTreeState">
|
|
||||||
<entry key="Project Default">
|
|
||||||
<profile-state>
|
|
||||||
<expanded-state>
|
|
||||||
<State>
|
|
||||||
<id />
|
|
||||||
</State>
|
|
||||||
</expanded-state>
|
|
||||||
<selected-state>
|
|
||||||
<State>
|
|
||||||
<id>Android</id>
|
|
||||||
</State>
|
|
||||||
</selected-state>
|
|
||||||
</profile-state>
|
|
||||||
</entry>
|
|
||||||
</component>
|
|
||||||
<component name="ProjectLevelVcsManager" settingsEditedManually="false">
|
|
||||||
<OptionsSetting value="true" id="Add" />
|
|
||||||
<OptionsSetting value="true" id="Remove" />
|
|
||||||
<OptionsSetting value="true" id="Checkout" />
|
|
||||||
<OptionsSetting value="true" id="Update" />
|
|
||||||
<OptionsSetting value="true" id="Status" />
|
|
||||||
<OptionsSetting value="true" id="Edit" />
|
|
||||||
<ConfirmationsSetting value="0" id="Add" />
|
|
||||||
<ConfirmationsSetting value="0" id="Remove" />
|
|
||||||
</component>
|
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" default="false" assert-keyword="true" jdk-15="true" project-jdk-name="rbenv: 2.1.5" project-jdk-type="RUBY_SDK" />
|
|
||||||
</project>
|
|
|
@ -1,8 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="ProjectModuleManager">
|
|
||||||
<modules>
|
|
||||||
<module fileurl="file://$PROJECT_DIR$/.idea/admi_facile.iml" filepath="$PROJECT_DIR$/.idea/admi_facile.iml" />
|
|
||||||
</modules>
|
|
||||||
</component>
|
|
||||||
</project>
|
|
|
@ -1,124 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="Palette2">
|
|
||||||
<group name="Swing">
|
|
||||||
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
|
|
||||||
</item>
|
|
||||||
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
|
|
||||||
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
|
|
||||||
<initial-values>
|
|
||||||
<property name="text" value="Button" />
|
|
||||||
</initial-values>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
|
||||||
<initial-values>
|
|
||||||
<property name="text" value="RadioButton" />
|
|
||||||
</initial-values>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
|
||||||
<initial-values>
|
|
||||||
<property name="text" value="CheckBox" />
|
|
||||||
</initial-values>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
|
|
||||||
<initial-values>
|
|
||||||
<property name="text" value="Label" />
|
|
||||||
</initial-values>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
|
||||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
|
||||||
<preferred-size width="150" height="-1" />
|
|
||||||
</default-constraints>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
|
||||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
|
||||||
<preferred-size width="150" height="-1" />
|
|
||||||
</default-constraints>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
|
||||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
|
||||||
<preferred-size width="150" height="-1" />
|
|
||||||
</default-constraints>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
|
||||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
|
||||||
<preferred-size width="150" height="50" />
|
|
||||||
</default-constraints>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
|
||||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
|
||||||
<preferred-size width="150" height="50" />
|
|
||||||
</default-constraints>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
|
||||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
|
||||||
<preferred-size width="150" height="50" />
|
|
||||||
</default-constraints>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
|
||||||
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
|
||||||
<preferred-size width="150" height="50" />
|
|
||||||
</default-constraints>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
|
|
||||||
<preferred-size width="150" height="50" />
|
|
||||||
</default-constraints>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
|
||||||
<preferred-size width="150" height="50" />
|
|
||||||
</default-constraints>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
|
||||||
<preferred-size width="200" height="200" />
|
|
||||||
</default-constraints>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
|
||||||
<preferred-size width="200" height="200" />
|
|
||||||
</default-constraints>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
|
||||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
|
|
||||||
<preferred-size width="-1" height="20" />
|
|
||||||
</default-constraints>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
|
|
||||||
</item>
|
|
||||||
</group>
|
|
||||||
</component>
|
|
||||||
</project>
|
|
|
@ -1,6 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="VcsDirectoryMappings">
|
|
||||||
<mapping directory="" vcs="" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
|
@ -422,3 +422,6 @@ DEPENDENCIES
|
||||||
unicorn
|
unicorn
|
||||||
web-console (~> 2.0)
|
web-console (~> 2.0)
|
||||||
webmock
|
webmock
|
||||||
|
|
||||||
|
BUNDLED WITH
|
||||||
|
1.10.4
|
||||||
|
|
|
@ -1,22 +0,0 @@
|
||||||
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
|
|
27
app/controllers/france_connect_controller.rb
Normal file
27
app/controllers/france_connect_controller.rb
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
class FranceConnectController < ApplicationController
|
||||||
|
def index
|
||||||
|
client = FranceConnectClient.new
|
||||||
|
|
||||||
|
session[:state] = SecureRandom.hex(16)
|
||||||
|
session[:nonce] = SecureRandom.hex(16)
|
||||||
|
|
||||||
|
authorization_uri = client.authorization_uri(
|
||||||
|
scope: [:profile, :email],
|
||||||
|
state: session[:state],
|
||||||
|
nonce: session[:nonce]
|
||||||
|
)
|
||||||
|
redirect_to authorization_uri
|
||||||
|
end
|
||||||
|
|
||||||
|
def callback
|
||||||
|
user_infos = FranceConnectService.retrive_user(params[:code])
|
||||||
|
|
||||||
|
unless user_infos.nil?
|
||||||
|
@user = User.find_for_france_connect(user_infos.email)
|
||||||
|
|
||||||
|
sign_in @user
|
||||||
|
|
||||||
|
redirect_to(controller: 'users/dossiers', action: :index)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,31 +0,0 @@
|
||||||
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
|
|
|
@ -1,28 +0,0 @@
|
||||||
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
|
|
||||||
# You should configure your model like this:
|
|
||||||
# devise :omniauthable, omniauth_providers: [:twitter]
|
|
||||||
|
|
||||||
# You should also create an action method in this controller like this:
|
|
||||||
# def twitter
|
|
||||||
# end
|
|
||||||
|
|
||||||
# More info at:
|
|
||||||
# https://github.com/plataformatec/devise#omniauth
|
|
||||||
|
|
||||||
# GET|POST /resource/auth/twitter
|
|
||||||
# def passthru
|
|
||||||
# super
|
|
||||||
# end
|
|
||||||
|
|
||||||
# GET|POST /users/auth/twitter/callback
|
|
||||||
# def failure
|
|
||||||
# super
|
|
||||||
# end
|
|
||||||
|
|
||||||
# protected
|
|
||||||
|
|
||||||
# The path used when omniauth fails
|
|
||||||
# def after_omniauth_failure_path_for(scope)
|
|
||||||
# super(scope)
|
|
||||||
# end
|
|
||||||
end
|
|
20
app/models/france_connect_client.rb
Normal file
20
app/models/france_connect_client.rb
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
class FranceConnectClient < OpenIDConnect::Client
|
||||||
|
|
||||||
|
def initialize params={}
|
||||||
|
@redirect_uri = 'http://localhost:3000/france_connect/callback'
|
||||||
|
@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'
|
||||||
|
|
||||||
|
super(
|
||||||
|
identifier: FRANCE_CONNECT.identifier,
|
||||||
|
secret: FRANCE_CONNECT.secret,
|
||||||
|
redirect_uri: @redirect_uri,
|
||||||
|
authorization_endpoint: @authorization_endpoint,
|
||||||
|
token_endpoint: @token_endpoint,
|
||||||
|
userinfo_endpoint: @userinfo_endpoint
|
||||||
|
)
|
||||||
|
|
||||||
|
self.authorization_code = params[:code] if params.has_key? :code
|
||||||
|
end
|
||||||
|
end
|
|
@ -5,4 +5,12 @@ class User < ActiveRecord::Base
|
||||||
:recoverable, :rememberable, :trackable, :validatable
|
:recoverable, :rememberable, :trackable, :validatable
|
||||||
|
|
||||||
has_many :dossiers
|
has_many :dossiers
|
||||||
|
|
||||||
|
def self.find_for_france_connect email
|
||||||
|
user = User.find_by_email(email)
|
||||||
|
|
||||||
|
return user unless user.nil?
|
||||||
|
|
||||||
|
User.create(email: email, password: Devise.friendly_token[0,20])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
12
app/services/france_connect_service.rb
Normal file
12
app/services/france_connect_service.rb
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
class FranceConnectService
|
||||||
|
def self.retrive_user code
|
||||||
|
client = FranceConnectClient.new code: code
|
||||||
|
|
||||||
|
begin
|
||||||
|
access_token = client.access_token!(client_auth_method: :secret)
|
||||||
|
access_token.userinfo!
|
||||||
|
rescue Exception => e
|
||||||
|
Rails.logger.error(e.message)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -6,6 +6,8 @@
|
||||||
<%= link_to "Sign up", new_registration_path(resource_name) %><br />
|
<%= link_to "Sign up", new_registration_path(resource_name) %><br />
|
||||||
<% end -%>
|
<% end -%>
|
||||||
|
|
||||||
|
<%= link_to "Connect with France Connect", '/france_connect' %><br />
|
||||||
|
|
||||||
<%- if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' %>
|
<%- if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' %>
|
||||||
<%= link_to "Forgot your password?", new_password_path(resource_name) %><br />
|
<%= link_to "Forgot your password?", new_password_path(resource_name) %><br />
|
||||||
<% end -%>
|
<% end -%>
|
||||||
|
|
|
@ -9,14 +9,17 @@ Rails.application.routes.draw do
|
||||||
}, skip: [:password, :registrations]
|
}, skip: [:password, :registrations]
|
||||||
|
|
||||||
|
|
||||||
|
root 'users/dossiers#index'
|
||||||
|
# root 'users/france_connect_callbacks#login'
|
||||||
|
|
||||||
# root 'users/dossiers#index'
|
|
||||||
root 'test_open_id#show'
|
get 'france_connect' => 'france_connect#index'
|
||||||
get '/fc' => 'fc#index'
|
get 'france_connect/callback' => 'france_connect#callback'
|
||||||
|
|
||||||
|
|
||||||
namespace :users do
|
namespace :users do
|
||||||
get 'siret' => 'siret#index'
|
get 'siret' => 'siret#index'
|
||||||
|
|
||||||
resources :dossiers do
|
resources :dossiers do
|
||||||
get '/description' => 'description#show'
|
get '/description' => 'description#show'
|
||||||
get '/description/error' => 'description#error'
|
get '/description/error' => 'description#error'
|
||||||
|
@ -29,7 +32,6 @@ Rails.application.routes.draw do
|
||||||
post '/commentaire' => 'commentaires#create'
|
post '/commentaire' => 'commentaires#create'
|
||||||
end
|
end
|
||||||
resource :dossiers
|
resource :dossiers
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue