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: [WIP] Implement OIDC sign-in #9251

Draft
wants to merge 217 commits into
base: main
Choose a base branch
from
Draft

feat: [WIP] Implement OIDC sign-in #9251

wants to merge 217 commits into from

Conversation

hangy
Copy link
Member

@hangy hangy commented Nov 6, 2023

What

The main aim is to use Keycloak as an IdP, and connect Product Opener as a RP. We want to move the basics of user management out of Product Opener.

In the future, this can be used as a base to enable #1204 to be implemented, even though it will probably not be part of the initial change as to not blow up the PR too much. One important requirement is to keep compatibility with the current Basic Auth mechanism.

Screenshot

TBD

Related issue(s) and discussion

Adding a task list to track progress:

  • @hangy: Move all interaction with user_emails.sto to call Keycloak APIs instead
  • @john-gom: Move all read and write operations to user.sto files to one place
  • Update user.sto read/write operations to get user "signup" fields from Keycloak (not required, as we want Keycloak as the canonical source)
  • @hangy: Pass country / language to login page
  • @hangy Add delete user event listener to Keycloak, trigger Redis event feat: Publish user deletion event to Redis openfoodfacts-auth#3
  • @hangy Store deleted users in a table feat: Store deleted users in a table openfoodfacts-auth#14
  • @hangy Redis event subscriber on Product Opener to remove user name from products (TBA extend to other applications) (WIP https://github.com/hangy/openfoodfacts-server/tree/keycloak-redis)
  • @john-gom: Add all "signup" fields to Keycloak and import language and country lists from taxonomy json
  • @john-gom: Fix locale pick list to be searchable
  • Upgrade to 24.0.0 when available and check localization is working for account page
  • Set up Crowdin translation project ci: Create crowdin.yml openfoodfacts-auth#2
  • @hangy Test with Mobile and other API usage scenarios
    • Flutter app seems to work fine
    • Hunger games shows user logged in (with modified hunger games branch, as main currently has a lot of hard coded URLs)
    • Write test with robotoff not that easy in separate setup 😞
  • @hangy Benchmark import of the number of users we have in production
    time ./scripts/migrate_users_to_keycloak.pl with around 400.000 synthetic accounts took about 45 minutes on my desktop PC in WSL2.

Save for a later phase:

  • HOLD on this pending unification. Live with inconsistent passwords for now. Update OPF, OBF and OPFF to login via Keycloak and redirect to OFF for user account info
  • Extend user attribute table to store more text
  • Select correct language / country for user after login redirect back to OFF
    Example: If the users was on fr.openfoodfacts.org before signing up, and they change their locale to Spanish during registration in Keycloak, do we want them to be redirected to a Spanish page instead?
    Problem: Differentiating between first login (because of registration) and subsequent login would have to be done based on whether or not ${userid}.sto exists.
  • Get Product Opener client to self register on initialization and store secret somewhere safe
    Advantage: The client secret does not have to be exposed to the admin. However, they'll have access to the secret anyways, unless we were to store the secret in some kind of HSM.
    Disadvantage: Some client configuration can be done during self-registration, but some necessary permissions like realm-management need to be configured manually by an admin, anyways.
  • Get rid of user.sto files completely
    To consider: This file currently contains information about the users' active sessions. Do we want to replace the opaque session identifier by an encrypted cookie? Also, we need some kind of directory to identify users that have used ProductOpener know if we have to do something when a deletion event comes in through Redis. (Obviously, this could be done in MongoDB or PostgreSQL instead, but is there a huge difference?)
  • Move API consumers to use client_credentials rather than login
  • Update mobile app to use Keycloak web forms for login (eg. OIDC Authorization Code Flow)
  • Figure out how/if org management should be done in Keycloak (Done in MongoDB)

Moved to openfoodfacts-auth:

cgi/oidc-callback.pl Outdated Show resolved Hide resolved
@github-actions github-actions bot added the ⭐ top pull request Top pull request. label Nov 8, 2023
@teolemon teolemon changed the title [WIP] feat: Implement OIDC sign-in feat: [WIP] Implement OIDC sign-in Nov 9, 2023
@github-actions github-actions bot added the 🏭 Producers Platform https://wiki.openfoodfacts.org/Platform_for_producers label Jul 27, 2024
@github-actions github-actions bot added the 💥 Merge Conflicts 💥 Merge Conflicts label Jul 29, 2024
@github-actions github-actions bot added 💥 Merge Conflicts 💥 Merge Conflicts and removed 💥 Merge Conflicts 💥 Merge Conflicts labels Aug 9, 2024
@github-actions github-actions bot removed the 💥 Merge Conflicts 💥 Merge Conflicts label Aug 13, 2024
@github-actions github-actions bot added the 💥 Merge Conflicts 💥 Merge Conflicts label Aug 27, 2024
@github-actions github-actions bot removed the 💥 Merge Conflicts 💥 Merge Conflicts label Sep 2, 2024
hangy and others added 6 commits September 8, 2024 12:59
This commit refactors the code in the `Display.pm` and `Keycloak.pm` files to update the generation of the keycloak account link. Previously, the `get_account_link` method in the `Keycloak.pm` file did not include the canonical URL of the current site in the generated link. This update adds the `url` parameter to the `get_account_link` method and modifies the link generation logic to include the canonical URL in the generated link.

The changes in the `Display.pm` file involve updating the usage of the `get_account_link` method to pass the `canon_url` parameter.

These changes improve the functionality and accuracy of the keycloak account link generation.

See openfoodfacts/openfoodfacts-auth#36
@github-actions github-actions bot added the 💥 Merge Conflicts 💥 Merge Conflicts label Sep 17, 2024
Copy link

sonarcloud bot commented Sep 19, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
1 Security Hotspot

See analysis details on SonarCloud

@github-actions github-actions bot removed the 💥 Merge Conflicts 💥 Merge Conflicts label Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Account deletion Enabling users to delete account while preserving accountability for edits 🧪 additives 🥜 Allergens 🪶 Apache We use Apache as a server to run Open Food Facts API READ All READ APIs include Product, Search… API v3 API WRITE WRITE API to allow sending product info and image API Issues related to the Open Food Facts API. More specific labels exist & should be used (API WRITE…) 🔐 Auth categories config dependencies Pull requests that update a dependency file Display 🐋 Docker https://docker-curriculum.com/ 📚 Documentation Documentation issues improve the project for everyone. ✏️ Editing - Auto Suggest Providing autosuggest for taxonomized fields. Mostly used in editing scenarii 🔐 external auth service GitHub Actions Pull requests that update Github_actions code 🥗🔍 Ingredients analysis https://wiki.openfoodfacts.org/Ingredients_Extraction_and_Analysis Ingredients processing 🥗 Ingredients JavaScript 👮 Moderation NGINX 🧴 Open Beauty Facts Our cosmetic analysis project https://world.openbeautyfacts.org 🐾 Open Pet Food Facts Our pet food analysis project https://world.openpetfoodfacts.org 📸 Open Products Facts Our project to increase the lifespan of objects. https://world.openproductsfacts.org 🎯 P1 🔐 Password 🏭 Producers Platform https://wiki.openfoodfacts.org/Platform_for_producers product history We have kept 10 years of product revisions. This is useful to monitor edits & product improvements Product Page Products REDIS Site layout ⭐ top pull request Top pull request. 🧬 Taxonomies https://wiki.openfoodfacts.org/Global_taxonomies Template::Toolkit The templating toolkit used by product opener. The starting point for HTML/JS/CSS fixes. 🧪 tests Translations We use a non-standard version of GetText, lack language variants support translate.openfoodfacts.org 🌐 Translations URL 👥 User management 👥 Users
Projects
Status: In progress
Status: In progress
Status: In progress
Status: In progress
Status: Todo
Status: In progress
Status: Backlog
Status: In progress
Development

Successfully merging this pull request may close these issues.

Implement a central User Service for auth - keycloak
5 participants