-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
144 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,11 +6,21 @@ | |
"instances" : 4, | ||
"exec_mode" : "cluster_mode", | ||
"env": { | ||
"NODE_ENV": "production", | ||
"PORT": 5000, | ||
"FC_CLIENT_ID": "abcdef", | ||
"FC_CLIENT_SECRET": "123456", | ||
"SESSION_SECRET": "foobar", | ||
|
||
"DOMAIN": "http://bourse.sgmap.fr", | ||
"FC_CLIENT_SECRET": "123456", | ||
|
||
"DGFIP_HOST": "rvxdusx001.dgfip.finances.gouv.fr", | ||
"DGFIP_BASE_URL": "https://rvxdusx001.dgfip.finances.gouv.fr/courtier/bourse", | ||
"DGFIP_CERT_LOCATION": "/path/to.cert", | ||
"DGFIP_KEY_LOCATION": "/path/to.key", | ||
|
||
"NODE_TLS_REJECT_UNAUTHORIZED": 0, | ||
|
||
"SMTP_USER": "[email protected]", | ||
"SMTP_PASS": "pass", | ||
"SMTP_HOST": "yourdomain.com" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
'use strict'; | ||
|
||
var express = require('express'); | ||
var passport = require('passport'); | ||
|
||
var router = express.Router(); | ||
|
||
router.get('/', function(req, res, next) { | ||
if (req.user && req.user.accessToken) { | ||
return res.redirect('https://app.franceconnect.gouv.fr/api/v1/logout?force'); | ||
} | ||
|
||
next(); | ||
}, passport.authenticate('france-connect')); | ||
|
||
router.get('/callback', passport.authenticate('france-connect', { failureRedirect: '/' }), function(req, res) { | ||
res.redirect('/nouvelle_demande/vos-ressources'); | ||
}); | ||
|
||
router.get('/logout', function(req, res) { | ||
req.logout(); | ||
res.redirect('https://app.franceconnect.gouv.fr/api/v1/logout?force'); | ||
}); | ||
|
||
module.exports = router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
var passport = require('passport'); | ||
var OAuth2Strategy = require('passport-oauth2').Strategy; | ||
var request = require('superagent'); | ||
|
||
exports.setup = function(config) { | ||
var strategy = new OAuth2Strategy({ | ||
authorizationURL: 'https://app.franceconnect.gouv.fr/api/v1/authorize', | ||
tokenURL: 'https://app.franceconnect.gouv.fr/api/v1/token', | ||
clientID: config.fc.clientId, | ||
clientSecret: config.fc.clientSecret, | ||
callbackURL: config.domain + '/oauth/fc/callback', | ||
scope: ['openid', 'profile', 'email', 'address', 'phone', 'dgfip_rfr', 'dgfip_nbpac', 'dgfip_sitfam', 'dgfip_nbpart'], | ||
state: 'foobar' | ||
}, | ||
function(accessToken, refreshToken, profile, done) { | ||
var user = profile; | ||
user.accessToken = accessToken; | ||
done(null, user); | ||
} | ||
|
||
); | ||
strategy.authorizationParams = function() { | ||
// Pour ne garder que le FI dgfip: | ||
// return { nonce: 'foobar', selected_idp: 'dgfip' }; | ||
return { nonce: 'foobar' }; | ||
}; | ||
|
||
strategy.userProfile = function(accessToken, done) { | ||
request | ||
.get('https://app.franceconnect.gouv.fr/api/v1/userinfo') | ||
.query({ schema: 'openid' }) | ||
.set('Authorization', 'Bearer ' + accessToken) | ||
.end(function(err, result) { | ||
if (err) return done(err); | ||
if (!result.body || !result.body.family_name) return done(new Error('Bad content')); | ||
done(null, result.body); | ||
}); | ||
}; | ||
|
||
passport.use('france-connect', strategy); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters