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

Act as OpenID Connect provider #11481

Closed
3 tasks
mkllnk opened this issue Aug 31, 2023 · 6 comments
Closed
3 tasks

Act as OpenID Connect provider #11481

mkllnk opened this issue Aug 31, 2023 · 6 comments

Comments

@mkllnk
Copy link
Member

mkllnk commented Aug 31, 2023

Description

An OpenID Connect (OIDC) provider can be used by other applications to authenticate users. We currently use login.lescommuns.org as provider to authenticate requests to the OFN DFC API. But by becoming a provider ourselves, we can authenticate users across OFN instances. That will allow a user of Open Food Network Germany to log into Open Food Network Belgium without setting a new password. And it will then allow the user to move DFC data between the instances. It will also allow new custom apps to use OFN accounts without requiring a sign-up process itself.

Acceptance Criteria & Tests

  1. Log into one OFN server using the account of another OFN server.

Existing code

The OFN DFC API verifies OIDC tokens against one provider already:

# Service used to authorize the user on DCF Provider API
# It controls an OICD Access token and an enterprise.
class AuthorizationControl
# Copied from: https://login.lescommuns.org/auth/realms/data-food-consortium/
LES_COMMUNES_PUBLIC_KEY = <<~KEY
-----BEGIN PUBLIC KEY-----

  • We want to generate a key pair for each OFN instance. The public keys need to be included in each instance. We can start by hard-coding them and later store them in ofn-install. Estimate 1 day.
  • Then we need to handle authentication requests and serve tokens. The tokens must include an expiry timestamp. The expiry should be reasonably short, maybe 20 minutes ans is only used for authentication. Estimate 3 days.
  • Lastly, we need a UI for the login within OFN. This should be feature-toggled to start with. When activated, the login-form has a button or link to log in with another OFN account. After clicking that link, the user has the choice of OFN platform to authenticate with. After choosing, the user is directed to that instance for authentication. The other instance may ask to log in if the user isn't logged in already. It then generates the token (see above) and passes it back to the first instance in a redirect. The first instance verifies the token, performs the login, or account creation if necessary, and the user is logged in. Estimate 3 days.

Since each OFN instance is an ID provider itself, it can generate tokens to authenticate any OFN DFC API requests from then on.

Estimate summary: 7 days.

@RachL
Copy link
Contributor

RachL commented Sep 1, 2023

Wooow! Are we sure we want to maintain our own OIDC server? I could be wrong but it seems to me like a lot of work. I would first enable other OIDC existing servers.

What's the need behind this @kirstenalarsen @lin-d-hop ?

@RachL
Copy link
Contributor

RachL commented Sep 1, 2023

Or maybe I misunderstood: this issue would enable to use a "login with lescommun" button and my current OIDC user on FR would be able to login on any OFN instance when this is done?

@mkllnk
Copy link
Member Author

mkllnk commented Sep 4, 2023

Are we sure we want to maintain our own OIDC server?

Thanks for questioning me here. There are free software solutions out there to deploy and use. So it's definitely worth looking at that option and comparing.

Becoming an OIDC provider came from two use cases:

  1. Exchange OFN data between instances via DFC. The user needs to be able to connect two OFN accounts on different instances to move data between them.
  2. We want to develop independent apps which connect to OFN accounts to exchange data via the DFC API.

In either case, we could authenticate via a third party but it would be much simpler for users to re-use their existing OFN account. There are several things to consider though:

  • login.lescommuns.org doesn't work for a global audience. We need a UI that's better branded and translated. And I'm not sure if any single site would serve all possible OFN users.
  • Pushing OFN as single-sign-on may be perceived as monopolising and an independent provider could have better acceptance.
  • We may want to support multiple providers though. So if a user wants to exchange data between OFN and XYZ then they need to log in with both and the app connects the tokens to exchange the data.
  • A single-sign-on server is simpler to implement then a multi-login-system.
  • Integrating OIDC into OFN increases maintenance within OFN but avoids the maintenance of an additional server with its own tech stack.
  • Integrating OIDC will probably allow us to create OFN-specific permissions for API exchanges. The alternative to this could be a DFC specific permission system implemented in a DFC managed OIDC server.

I don't think that I can decide this on my own. I'm not even that familiar with OIDC providers. But since we do manage user accounts and have an API, it does make sense to me to authenticate with OFN servers as well. Or, we go into a completely different direction, get rid of OFN instance accounts and move to a global single-sign-on server. That would be much simpler but makes instances also less independent and they become vulnerable to this single point of failure. I would prefer to build on our distributed network of instances and find a scalable solution without compromising user choice on privacy etc.

And it's not like we have to implement everything from scratch. We use an existing library for OIDC for which we just need to add the UX and our custom logic. We could discuss this at the delivery circle but the team probably doesn't know enough about the topic yet. Maybe @Matt-Yorkley and I should have a chat about this first? Shall we work out a time?

@RachL
Copy link
Contributor

RachL commented Sep 4, 2023

Yes sorry I took lescommuns as an example but I def. agree they don't work as a global audience.

It seems to me a bit outside of OFN league to become an auth provider. I fear the monopolistic aspect, but you did a very good summary of the situation, so I don't have anything to add - thanks :)

Looking forward to hear what conclusion will come up from your chat!

@RachL
Copy link
Contributor

RachL commented Sep 15, 2023

@mkllnk
Copy link
Member Author

mkllnk commented Mar 18, 2024

I'll close this for now. I don't think that we have a strong enough case for this work. We can setup a global OFN Keycloak if we want. OFN being a provider would simplify some user stories because people don't need to sign up with another server as well. But we don't want to make our code base bigger when there's another solution.

@mkllnk mkllnk closed this as completed Mar 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Status: Done
Development

No branches or pull requests

2 participants