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

Open
wants to merge 268 commits into
base: main
Choose a base branch
from
Open

feat: Implement OIDC sign-in #9251

wants to merge 268 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 Template::Toolkit The templating toolkit used by product opener. The starting point for HTML/JS/CSS fixes. Translations We use a non-standard version of GetText, lack language variants support translate.openfoodfacts.org 🔐 Password labels Nov 21, 2023
@github-actions github-actions bot added the API Issues related to the Open Food Facts API. More specific labels exist & should be used (API WRITE…) label Nov 26, 2023
@github-actions github-actions bot removed the 💥 Merge Conflicts 💥 Merge Conflicts label Nov 26, 2024
Signed-off-by: John Gomersall <thegoms@gmail.com>
Signed-off-by: John Gomersall <thegoms@gmail.com>
Signed-off-by: John Gomersall <thegoms@gmail.com>
Signed-off-by: John Gomersall <thegoms@gmail.com>
@github-actions github-actions bot added the 💥 Merge Conflicts 💥 Merge Conflicts label Nov 28, 2024
john-gom and others added 2 commits December 2, 2024 14:47
Signed-off-by: John Gomersall <thegoms@gmail.com>
@github-actions github-actions bot added 💥 Merge Conflicts 💥 Merge Conflicts and removed 💥 Merge Conflicts 💥 Merge Conflicts labels Dec 5, 2024
@hangy
Copy link
Member Author

hangy commented Dec 7, 2024

/update_tests_results

@github-actions github-actions bot removed the 💥 Merge Conflicts 💥 Merge Conflicts label Dec 9, 2024
Signed-off-by: John Gomersall <thegoms@gmail.com>
Signed-off-by: John Gomersall <thegoms@gmail.com>
Signed-off-by: John Gomersall <thegoms@gmail.com>
Signed-off-by: John Gomersall <thegoms@gmail.com>
Signed-off-by: John Gomersall <thegoms@gmail.com>
Signed-off-by: John Gomersall <thegoms@gmail.com>
Signed-off-by: John Gomersall <thegoms@gmail.com>
Signed-off-by: John Gomersall <thegoms@gmail.com>
Signed-off-by: John Gomersall <thegoms@gmail.com>
Signed-off-by: John Gomersall <thegoms@gmail.com>
Signed-off-by: John Gomersall <thegoms@gmail.com>
Signed-off-by: John Gomersall <thegoms@gmail.com>
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 Agribalyse French LCA database used in Eco-Score computations 🥜 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 Data import dependencies Pull requests that update a dependency file Display 🐋 Docker https://docker-curriculum.com/ 📚 Documentation Documentation issues improve the project for everyone. 🌱 Eco-Score https://world.openfoodfacts.org/eco-score-the-environmental-impact-of-food-products ✏️ Editing - Auto Suggest Providing autosuggest for taxonomized fields. Mostly used in editing scenarii ✏️ Editing 🔐 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 Minion 👮 Moderation multilingual products 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 📚 OpenAPI 🏭 Orgs 🎯 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. 🤳🥫 tagline System to provide the mobile app with news 🧬 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
Development

Successfully merging this pull request may close these issues.

Implement a central User Service for auth - keycloak
5 participants