Skip to content

[17.0][IMP] auth_oidc: add groups' handling - #682

Open
OdyX wants to merge 11 commits into
OCA:17.0from
liip-forks:17-auth-oidc-groups-sync
Open

OdyX wants to merge 11 commits into
OCA:17.0from
liip-forks:17-auth-oidc-groups-sync

Conversation

@OdyX

@OdyX OdyX commented Aug 28, 2024

Copy link
Copy Markdown

This allows groups' handling via a token's attributes as passed by either a Keycloak or a Gitlab instance serving as IdP.

@sbidoul : I'd be happy to make any necessary changes!

@OCA-git-bot

Copy link
Copy Markdown
Contributor

Hi @sbidoul,
some modules you are maintaining are being modified, check this out!

@OdyX
OdyX force-pushed the 17-auth-oidc-groups-sync branch 2 times, most recently from ae41059 to 96788d5 Compare August 28, 2024 15:23
@hbrunn

hbrunn commented Sep 2, 2024

Copy link
Copy Markdown
Member

the v14 PR is based on my v12 PR which was merged - why didn't you just forward port this?

@OdyX

OdyX commented Sep 2, 2024

Copy link
Copy Markdown
Author

@hbrunn thanks for asking! As I'm quite fresh in the Odoo ecosystem, I did not see the v12 PR. Care to share a link?

As you can see from the code, my patch works a bit differently; as it appeared that what I needed for group mapping was directly in the access token, there's no usage of the data_endpoint. But I'm also likely not fluent enough in OAuth2 to know if that is really a correct way too.

Well; in any case, I'm happy to work towards merging either this or your v12 PR (or a mix of both) for v17. We need @sbidoul 's input, right?

@hbrunn

hbrunn commented Sep 3, 2024

Copy link
Copy Markdown
Member

you find the v12 PR here

@OdyX
OdyX force-pushed the 17-auth-oidc-groups-sync branch from 96788d5 to b360551 Compare September 6, 2024 15:09
@OdyX

OdyX commented Sep 6, 2024

Copy link
Copy Markdown
Author

@hbrunn Great. Thanks for the pointer to the v12 PR. I've now understood the code much better, and did a mostly-straightforward port, with just two minor additions as separate commits. Could you perhaps review?

@OdyX

OdyX commented Sep 11, 2024

Copy link
Copy Markdown
Author

As the codecov warnings seem critical, I've now added some more tests around the safe_eval call of the expressions.

Edit: and now also added some groups' assignment/deassignment checks, pushing the codecov bar above the needed limits.

@OdyX
OdyX force-pushed the 17-auth-oidc-groups-sync branch from a242ae4 to 7587cf0 Compare September 13, 2024 15:24

@hbrunn hbrunn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, just minor stylistic things

Comment thread auth_oidc/models/res_users.py Outdated
Comment thread auth_oidc/models/res_users.py Outdated
@hbrunn hbrunn closed this Nov 21, 2024
@hbrunn hbrunn reopened this Nov 21, 2024
@hbrunn

hbrunn commented Nov 21, 2024

Copy link
Copy Markdown
Member

@OdyX please rebase your branch. If you allow edits by maintainers, I could say

/ocabot rebase

and it would do this automatically

@OCA-git-bot

Copy link
Copy Markdown
Contributor

@hbrunn The rebase process failed, because command git rebase origin/17.0 failed with output:

Rebasing (1/10)
Auto-merging auth_oidc/__manifest__.py
Auto-merging auth_oidc/demo/local_keycloak.xml
CONFLICT (content): Merge conflict in auth_oidc/demo/local_keycloak.xml
Auto-merging auth_oidc/models/auth_oauth_provider.py
CONFLICT (content): Merge conflict in auth_oidc/models/auth_oauth_provider.py
Auto-merging auth_oidc/tests/test_auth_oidc_auth_code.py
Auto-merging auth_oidc/views/auth_oauth_provider.xml
CONFLICT (content): Merge conflict in auth_oidc/views/auth_oauth_provider.xml
error: could not apply 3e0bcb53... [IMP] auth_oidc: allow assign groups from token claims
hint: Resolve all conflicts manually, mark them as resolved with
hint: "git add/rm <conflicted_files>", then run "git rebase --continue".
hint: You can instead skip this commit: run "git rebase --skip".
hint: To abort and get back to the state before "git rebase", run "git rebase --abort".
Could not apply 3e0bcb53... [IMP] auth_oidc: allow assign groups from token claims

@OdyX
OdyX force-pushed the 17-auth-oidc-groups-sync branch 2 times, most recently from 8f270be to b9318fa Compare November 21, 2024 07:38
@OdyX

OdyX commented Nov 21, 2024

Copy link
Copy Markdown
Author

@hbrunn integrated your suggestions in afd10ea; and I have rebased this on top of 17.0.

@OdyX
OdyX force-pushed the 17-auth-oidc-groups-sync branch from b9318fa to 7f29f85 Compare February 12, 2025 15:20
@OdyX

OdyX commented Feb 12, 2025

Copy link
Copy Markdown
Author

Rebased and pushed. It would be nice to have @sbidoul 's input and get this merged (or commented upon).

@sbidoul sbidoul left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry folks for the delay.

I've not had time to do a deep review yet, but I have a couple a questions from a first read.

Comment thread auth_oidc/models/res_users.py Outdated
Comment thread auth_oidc/models/res_users.py
@OdyX
OdyX force-pushed the 17-auth-oidc-groups-sync branch 2 times, most recently from c09d1f2 to bc39e7b Compare February 21, 2025 13:41
@OdyX

OdyX commented Jun 11, 2025

Copy link
Copy Markdown
Author

@sbidoul Could you perhaps take another look?

Comment thread auth_oidc/models/auth_oauth_provider.py
Comment thread auth_oidc/models/res_users.py Outdated
@OdyX
OdyX force-pushed the 17-auth-oidc-groups-sync branch 2 times, most recently from 39c559c to 61c630f Compare August 21, 2025 20:57
@OdyX

OdyX commented Aug 21, 2025

Copy link
Copy Markdown
Author

@sbidoul Force-pushed a rebase with the comment suggestion included in the first commit. (twice because I forgot about pre-commit).

@sbidoul

sbidoul commented Aug 22, 2025

Copy link
Copy Markdown
Member

I'm not comfortable with replacing upstream method completely. Is there no other way? It is not clear to me why it is necessary for this PR but I have unfortunately no time to dig into this until October.

@OdyX
OdyX force-pushed the 17-auth-oidc-groups-sync branch 3 times, most recently from 583c517 to 77c5c2d Compare October 22, 2025 12:18
@OdyX

OdyX commented Oct 22, 2025

Copy link
Copy Markdown
Author

@sbidoul I managed to dive back into this code again.

I'm not comfortable with replacing upstream method completely. Is there no other way?

It turns out, there is. See 77c5c2d . In there, we just delete the duplicated code from auth_oauth, and merge the id_token and userinfo data into validation.

I'd be thrilled if we could merge this in 17.0, and I'd then be happy with forward porting these to 18.0 and 19.0 as needed.

(edited: sorry for the multiple force-pushes; tests turned out to be… relevant :-) )

@OdyX
OdyX force-pushed the 17-auth-oidc-groups-sync branch from 77c5c2d to 89a2a5f Compare October 24, 2025 08:56
@OdyX

OdyX commented Oct 24, 2025

Copy link
Copy Markdown
Author

I'm not comfortable with replacing upstream method completely. Is there no other way?

It turns out, after more tests and a (yet) better understanding of the code, doing so is actually worse than using the upstream code: the "Authorization: Bearer" is behind a system-level toggle, which makes things unnecessarily confusing and hard to debug.

I finally went with just a copy of the response checker in 89a2a5f (and I could live without that last commit).

@github-actions

github-actions Bot commented Mar 1, 2026

Copy link
Copy Markdown

There hasn't been any activity on this pull request in the past 4 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days.
If you want this PR to never become stale, please ask a PSC member to apply the "no stale" label.

@github-actions github-actions Bot added the stale PR/Issue without recent activity, it'll be soon closed automatically. label Mar 1, 2026
@OdyX

OdyX commented Mar 1, 2026

Copy link
Copy Markdown
Author

I would really love this being merged. As far as I can tell, this is ready and just missing validation from @sbidoul .

So please remove this stale label.

@github-actions github-actions Bot removed the stale PR/Issue without recent activity, it'll be soon closed automatically. label Mar 8, 2026
@github-actions

Copy link
Copy Markdown

There hasn't been any activity on this pull request in the past 4 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days.
If you want this PR to never become stale, please ask a PSC member to apply the "no stale" label.

@github-actions github-actions Bot added the stale PR/Issue without recent activity, it'll be soon closed automatically. label Jul 12, 2026
@sbidoul sbidoul removed the stale PR/Issue without recent activity, it'll be soon closed automatically. label Jul 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants