Skip to content

Commit

Permalink
Merge pull request #236 from betagouv/main
Browse files Browse the repository at this point in the history
Release 1.15.2
  • Loading branch information
estellecomment authored Jul 12, 2022
2 parents 7270451 + 07d0fee commit b8405a1
Show file tree
Hide file tree
Showing 16 changed files with 30 additions and 356 deletions.
2 changes: 2 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,5 @@ ENCRYPT_SECRET=un_secret_avec_exactement_64_bit
#OIDC_PROVIDER_URL=
#OIDC_CLIENT_ID=
#OIDC_CLIENT_SECRET=

#RIZOMO_URI=
2 changes: 1 addition & 1 deletion .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:

strategy:
matrix:
node-version: [12.x, 14.x]
node-version: [12.x, 14.x, 16.x]

steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ npm test

### Tester manuellement l'application
1. Se connecter sur http://localhost:8080
2. Remplir son email et son horaire
2. Remplir son adresse mail et son horaire
3. Consulter le http://localhost:1080/#/ pour voir l'email envoyé par le service


Expand Down
2 changes: 2 additions & 0 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,6 @@ config.OIDC_PROVIDER_URL = process.env.OIDC_PROVIDER_URL
config.OIDC_CLIENT_ID = process.env.OIDC_CLIENT_ID
config.OIDC_CLIENT_SECRET = process.env.OIDC_CLIENT_SECRET

config.RIZOMO_URI = process.env.RIZOMO_URI

module.exports = config
1 change: 1 addition & 0 deletions controllers/landingController.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,6 @@ module.exports.getLanding = async (req, res) => {
dateChoices: dateChoices,
FEATURE_RESERVATIONS: config.FEATURE_RESERVATIONS,
announcements: config.ANNOUNCEMENTS,
rizomoURI: config.RIZOMO_URI
})
}
6 changes: 3 additions & 3 deletions lib/magicLinkAuth.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ const generateToken = () => {

module.exports.startAuth = async (email, conferenceDurationInMinutes, conferenceDayString, userTimezoneOffset) => {
if (!isValidEmail(email)) {
return { error: "Email invalide. Avez vous bien tapé votre email ? Vous pouvez réessayer." }
return { error: "Adresse mail invalide. Avez vous bien tapé votre adresse mail ? Vous pouvez réessayer." }
}

if (!isAcceptedEmail(email, config.EMAIL_WHITELIST)) {
return { error: "Cet email ne correspond pas à une agence de l'État. Si vous appartenez à un service de l'État mais votre email n'est pas reconnu par AudioConf, contactez-nous pour que nous le rajoutions!" }
return { error: "Cette adresse mail ne correspond pas à une agence de l'État. Si vous appartenez à un service de l'État mais votre adresse mail n'est pas reconnue par AudioConf, contactez-nous pour que nous la rajoutions!" }
}

const token = generateToken()
Expand Down Expand Up @@ -71,7 +71,7 @@ module.exports.finishAuth = async (req) => {
const isTokenValid = confDatas.length === 1
if (!isTokenValid) {
// todo use propoer error codes ?
return { error: "Ce lien de confirmation ne marche plus, il a expiré. Entrez votre email ci-dessous pour recommencer." }
return { error: "Ce lien de confirmation ne marche plus, il a expiré. Entrez votre adresse mail ci-dessous pour recommencer." }
}

const confData = confDatas[0]
Expand Down
9 changes: 2 additions & 7 deletions lib/oidcAuth.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ module.exports.startAuth = async (email, conferenceDurationInMinutes, conference
const code_challenge = generators.codeChallenge(code_verifier);
*/

// "state" will be sent back by the oidc server.
// "state" will be sent back by the oidc server.
// It is there to protect the end user from cross site request forgery(CSRF) attacks.
// We also use it to identify the auth request at the end of the flow.
const state = generators.random(128)
Expand Down Expand Up @@ -68,7 +68,6 @@ module.exports.startAuth = async (email, conferenceDurationInMinutes, conference
return { error: "Une erreur interne s'est produite, nous n'avons pas pu créer votre conférence." }
}

// todo : how to deal with expiration of request in oidc ?
return { redirectUrl }
}

Expand All @@ -77,7 +76,6 @@ const fetchRequestFromDb = async (state) => {

const isRequestValid = requests.length === 1
if (!isRequestValid) {
// todo use propoer error codes ?
throw new Error("Multiple oidcRequests found for the given state")
}
return requests[0]
Expand All @@ -86,17 +84,15 @@ const fetchRequestFromDb = async (state) => {
module.exports.finishAuth = async (req) => {
const client = await this.getClient()
const params = client.callbackParams(req)
console.log("params passed to callback", params)

// todo : fetch code_verifier from DB. If no code_verifier, abort.
let request
try {
request = await fetchRequestFromDb(params.state)
} catch (e) {
console.error("error when fetching oidc request from DB", e)
return { error: "L'identification a échoué. Entrez votre email ci-dessous pour recommencer." }
return { error: "L'identification a échoué. Entrez votre adresse mail ci-dessous pour recommencer." }
}
console.log("found corresponding request", request)

const tokenSet = await client.callback(
config.HOSTNAME_WITH_PROTOCOL + urlCallback,
Expand All @@ -108,7 +104,6 @@ module.exports.finishAuth = async (req) => {
}
)
const claims = tokenSet.claims()
console.log("claims decoded from tokenset", claims)
const email = claims.preferred_username

return {
Expand Down
Loading

0 comments on commit b8405a1

Please sign in to comment.