Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(auth): allow Auth0 as authentication server, after bulk user import #705

Merged
merged 49 commits into from Oct 15, 2023

Conversation

adrienjoly
Copy link
Member

@adrienjoly adrienjoly commented Sep 2, 2023

Fork of PR #593. May contribute to #669.

What does this PR do / solve?

Make Openwhyd more secure by delegating auth and user management to Auth0.

Overview of changes

When Auth0 env vars are provided, Openwhyd delegates the following features to Auth0:

  • login/logout
  • signup
  • password change (forgotten or not)
  • ...

Otherwise, the legacy auth and user management implementation is used, as currently.

How to test this PR?

Prerequisite

To do once for all:

  1. setup a Auth0 account with a "user-password" auth database, with "usernames" login enabled
  2. paste Auth0 credentials to env-vars-testing.conf
  3. (re)start openwhyd + db in docker: $ docker compose up --build --detach
  4. seed test users: $ make docker-seed

To repeat after each code change:

  1. (re)start openwhyd + db: $ make dev

=> when you're done testing, don't forget to run $ make down.

Bulk user import

  1. copy-paste this token to file: scripts/auth0/.token
  2. run $ scripts/auth0/import-test-users.sh
  3. check that users are imported: Users + Logs

Login+logout

  1. open http://localhost:8080
  2. click on "log in" => you're redirected to auth0's login page
  3. login with admin/admin or dummy/admin
  4. back on openwhyd, logout

Signup

  1. open http://localhost:8080
  2. click on "sign up" => you're redirected to auth0's signup page
  3. submit a username (e.g. adrien), an email address and a password
  4. back on openwhyd, logout
  5. follow the "login+logout" procedure (above), to check that you can login with username or email

Change of email address

Once you're logged in:

  1. open http://localhost:8080/settings
  2. change the email address
  3. click "save changes", ignore the error message
  4. check that the email address was updated, in Auth0's user list

Change of password

Once you're logged in:

  1. open http://localhost:8080/settings
  2. click on the "password" tab
  3. type the same password in the 3 fields (any valid value will do)
  4. click "save changes" => a message tells you that you'll receive an email
  5. logout
  6. open the email, click the link, pick a new password
  7. back on http://localhost:8080, login with your new password

Change of handle/username

Once you're logged in:

  1. open http://localhost:8080/settings
  2. type a username in the "Custom URL" field
  3. click "save changes"
  4. logout
  5. login with your new username+password

Account deletion

Once you're logged in:

  1. open http://localhost:8080/settings
  2. click on "delete your account" and confirm
  3. check that the user is not listed anymore in Auth0's user list

TODO / probably worth doing before meging

To be done later

  • forward change of avatar to Auth0

References and resources

@codacy-production
Copy link

codacy-production bot commented Sep 2, 2023

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
Report missing for 66527711 39.55%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (6652771) Report Missing Report Missing Report Missing
Head commit (ab5811f) 5043 2983 59.15%

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#705) 134 53 39.55%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

Footnotes

  1. Codacy didn't receive coverage data for the commit, or there was an error processing the received data. Check your integration for errors and validate that your coverage setup is correct.

adrienjoly added a commit that referenced this pull request Sep 5, 2023
…k with the legacy signup page

contributes to #705.
adrienjoly pushed a commit that referenced this pull request Sep 5, 2023
## [1.55.62](v1.55.61...v1.55.62) (2023-09-05)

### Bug Fixes

* **auth:** we need to create a /signup route for Auth0 => make it work with the legacy signup page ([d3e2592](d3e2592)), closes [#705](#705)
@adrienjoly
Copy link
Member Author

@julien-topcu Te sens pas obligé de faire une full review, mais je suis preneur de ton avis les changements et le mode opératoire que j'ai décris dans la description de cette PR, ainsi que tes réponses éventuelles aux questions ouvertes postées sur Notion, quand tu auras un peu de temps.

Je laisse ce chantier en stand-by d'ici là, histoire d'éviter d'aller trop loin dans une direction potentiellement contre-productive.

@adrienjoly adrienjoly marked this pull request as ready for review September 7, 2023 13:18
adrienjoly added a commit that referenced this pull request Sep 11, 2023
- argon2                     ^0.31.0  →  ^0.31.1, because we're developing an alternative: #705
- connect-mongo               ^3.2.0  →   ^5.0.0, because we're developing an alternative: #705
- formidable                  ^2.1.1  →   ^3.5.1, because it breaks the build (cf #709 and #665)
- mongodb                     4.17.0  →    6.0.0, because we're not done yet on migrative callbacks to promises (cf #634 and #665)

This partially reverts commit 43a63cf.
adrienjoly added a commit that referenced this pull request Sep 11, 2023
`$ npx npm-check-updates -u`

Updates:

- @applitools/eyes-cypress   ^3.37.0  →  ^3.38.0
- @cypress/code-coverage     ^3.11.0  →  ^3.12.0
- @types/node                ^20.5.7  →  ^20.6.0
- approvals                   ^6.2.1  →   ^6.2.2
- cypress                   ^12.17.4  →  ^13.1.0
- dd-trace                   ^4.14.0  →  ^4.15.0
- eslint                     ^8.48.0  →  ^8.49.0

Skipped updates:

- argon2                     ^0.31.0  →  ^0.31.1, because we're developing an alternative: #705
- connect-mongo               ^3.2.0  →   ^5.0.0, because we're developing an alternative: #705
- formidable                  ^2.1.1  →   ^3.5.1, because it breaks the build (cf #709 and #665)
- mongodb                     4.17.0  →    6.0.0, because we're not done yet on migrative callbacks to promises (cf #634 and #665)
@adrienjoly adrienjoly changed the title feat(security): use Auth0 as authentication server, after bulk user import feat(auth): allow Auth0 as authentication server, after bulk user import Oct 15, 2023
@adrienjoly adrienjoly merged commit a65723f into main Oct 15, 2023
18 of 20 checks passed
@adrienjoly adrienjoly deleted the auth0-after-bulk-user-import branch October 15, 2023 12:38
adrienjoly pushed a commit that referenced this pull request Oct 15, 2023
# [1.58.0](v1.57.1...v1.58.0) (2023-10-15)

### Features

* **auth:** allow Auth0 as authentication server, after bulk user import ([#705](#705)) ([a65723f](a65723f)), closes [#593](#593) [#669](#669) [#658](#658)
@adrienjoly
Copy link
Member Author

This PR is now running in production, but without using Auth0 yet.

adrienjoly added a commit that referenced this pull request Dec 27, 2023
Follow up of #705. May contribute to #669.

Usage, from project root dir:

```sh
$ mongoexport -d ${dbname} -c user --type=json --out ./prod-users.json-lines -u ${dbuser} -p ${dbpassword}
$ node ./scripts/auth0/prepare-import-batches.js # => create files: `prod-users-*.for-auth0.json`
$ ./scripts/auth0/import-prod-users.sh
```
adrienjoly pushed a commit that referenced this pull request Dec 27, 2023
## [1.59.4](v1.59.3...v1.59.4) (2023-12-27)

### Bug Fixes

* **auth:** add scripts to import users to auth0 ([#755](#755)) ([d55d0f3](d55d0f3)), closes [#705](#705) [#669](#669)
adrienjoly added a commit that referenced this pull request Mar 9, 2024
adrienjoly pushed a commit that referenced this pull request Mar 9, 2024
## [1.59.15](v1.59.14...v1.59.15) (2024-03-09)

### Bug Fixes

* **auth:** try to refresh auth0 session silently, without having to re-login everyday ([c8fb684](c8fb684)), closes [#705](#705)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

migrate Facebook calls to Graph API v≥12.0, before Mid September 2023
1 participant