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

Adding group claim name for admin and required does not show in gui #18388

Closed
netcicd opened this issue Jan 24, 2022 · 4 comments · Fixed by #18412
Closed

Adding group claim name for admin and required does not show in gui #18388

netcicd opened this issue Jan 24, 2022 · 4 comments · Fixed by #18412

Comments

@netcicd
Copy link

netcicd commented Jan 24, 2022

Gitea Version

1.16.0-rc1

Git Version

No response

Operating System

docker: gitea/gitea:1.16.0-rc1

How are you running Gitea?

docker container as part of https://github.com/Devoteam/CICD-toolbox

Database

PostgreSQL

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Description

when running
gitea admin auth update-oauth --id 1 --required-claim-name gitea-admin --admin-group gitea-admin
in the container, this does not show in the gui. Adding these fields in the gui gives 200 in the log, but no entry in the gui

Screenshots

Screenshot from 2022-01-24 16-04-53
secret in picture is randomly generated

@netcicd
Copy link
Author

netcicd commented Jan 24, 2022

When set in the GUI, Additional scopes and Group claim name for administrators show up in the database. Required shows up when entered on CLI, not in GUI
When updating entry in GUI, I get a http 500 error, even when nothing changed.

Before update:

{"Provider":"openidConnect","ClientID":"Gitea","ClientSecret":"1057f9ac-3acd-456a-8c06-61180ad9d8a0","OpenIDConnectAutoDiscoveryURL":"http://keycloak.tooling.test:8080/auth/realms/netcicd/.well-known/openid-configuration","CustomURLMapping":{},"IconURL":"","Scopes":[],"RequiredClaimName":"gitea-admin","RequiredClaimValue":"","GroupClaimName":"gitea-group","AdminGroup":"gitea-admin","RestrictedGroup":""}

After update:

{"Provider":"openidConnect","ClientID":"Gitea","ClientSecret":"1057f9ac-3acd-456a-8c06-61180ad9d8a0","OpenIDConnectAutoDiscoveryURL":"http://keycloak.tooling.test:8080/auth/realms/netcicd/.well-known/openid-configuration","CustomURLMapping":{},"IconURL":"","Scopes":[""],"RequiredClaimName":"","RequiredClaimValue":"gitea-admin","GroupClaimName":"","AdminGroup":"","RestrictedGroup":""}

restoring the data makes no difference...

When updated through CLI with gitea admin auth update-oauth --id 1 --required-claim-name gitea-admin --admin-group gitea-admin, it works when I provide the gitea-admin claim but the user is not admin.

When the group-claim-name is updated through the CLI
gitea admin auth update-oauth --id 1 --group-claim-name gitea-group

and a corresponding claim is made in Keycloak:
Screenshot from 2022-01-24 22-45-04

This is the associated jwt
{
"exp": 1643059571,
"iat": 1643059271,
"auth_time": 1643059248,
"jti": "4ccd708c-efeb-43ed-bfcb-55cf04f3f1c7",
"iss": "http://keycloak.tooling.test:8080/auth/realms/netcicd",
"sub": "060bbc59-b1a2-4bf9-b1cc-ca2bd2541830",
"typ": "Bearer",
"azp": "Gitea",
"session_state": "6943341b-488b-4880-8e7e-148d21035364",
"acr": "0",
"allowed-origins": [
"http://gitea.tooling.test:3000/"
],
"resource_access": {
"Gitea": {
"roles": [
"gitea-admin"
]
}
},
"scope": "openid profile email",
"sid": "6943341b-488b-4880-8e7e-148d21035364",
"email_verified": false,
"gitea-group": [
"gitea-admin"
],
"name": "NetCICD Godmode Godmode",
"gitea-admin": [
"gitea-admin"
],
"preferred_username": "netcicd",
"given_name": "NetCICD Godmode",
"family_name": "Godmode",
"email": "[email protected]"
}

And for an ordinary user:
{
"exp": 1643059860,
"iat": 1643059560,
"auth_time": 1643059560,
"jti": "9797e414-4a90-4068-b508-dd660f6d8413",
"iss": "http://keycloak.tooling.test:8080/auth/realms/netcicd",
"sub": "599b0c23-56f1-427d-a4d1-fe6a601d72cc",
"typ": "Bearer",
"azp": "Gitea",
"session_state": "cd5cd945-422d-46b3-bd3c-1fa8311ae52a",
"acr": "1",
"allowed-origins": [
"http://gitea.tooling.test:3000/"
],
"resource_access": {
"Gitea": {
"roles": [
"gitea-netcicd-read"
]
}
},
"scope": "openid profile email",
"sid": "cd5cd945-422d-46b3-bd3c-1fa8311ae52a",
"email_verified": false,
"gitea-group": [
"gitea-netcicd-read"
],
"name": "Net Dude Dude",
"gitea-admin": [
"gitea-netcicd-read"
],
"preferred_username": "netdude",
"given_name": "Net Dude",
"family_name": "Dude",
"email": "[email protected]"
}

and as shown, the ordinary user is in the group gitea-netcicd-read, this group has read access:
Screenshot from 2022-01-24 22-32-11

but cannot see the repo:
Screenshot from 2022-01-24 22-35-17

It would be much more convenient if the implementation would just read the default resource_access claim for the Client_ID where the roles are the group names...

@zeripath
Copy link
Contributor

The rendering in your screenshots appears to be a little odd.

Do you have old custom templates?

@netcicd
Copy link
Author

netcicd commented Jan 25, 2022

Hi Zeripath,
No custom templates, just the container I downloaded from docker hub. I selected the relevant portions of the screens.
What I'll do is purge my docker images and rebuild.
Nothing changed after rebuild in the images...

zeripath added a commit to zeripath/gitea that referenced this issue Jan 25, 2022
It appears that there was a broken merge of the edit.tmpl page during the merge
of go-gitea#16594 - I am not entirely sure how this happened as the PR was correct.

This PR fixes the broken template.

Fix go-gitea#18388

Signed-off-by: Andrew Thornton <[email protected]>
@zeripath
Copy link
Contributor

OK the edit page template looks to have suffered a conflict merge at some point and it got broke.

diff --git a/templates/admin/auth/edit.tmpl b/templates/admin/auth/edit.tmpl
index a9942354c..efa440ff3 100644
--- a/templates/admin/auth/edit.tmpl
+++ b/templates/admin/auth/edit.tmpl
@@ -286,6 +286,10 @@
 							<input id="skip_local_two_fa" name="skip_local_two_fa" type="checkbox" {{if $cfg.SkipLocalTwoFA}}checked{{end}}>
 							<p class="help">{{.i18n.Tr "admin.auths.skip_local_two_fa_helper"}}</p>
 						</div>
+					</div>
+					<div class="oauth2_use_custom_url inline field">
+						<div class="ui checkbox">
+							<label><strong>{{.i18n.Tr "admin.auths.oauth2_use_custom_url"}}</strong></label>
 							<input id="oauth2_use_custom_url" name="oauth2_use_custom_url" type="checkbox" {{if $cfg.CustomURLMapping}}checked{{end}}>
 						</div>
 					</div>

would fix the template.

6543 pushed a commit that referenced this issue Jan 26, 2022
It appears that there was a broken merge of the edit.tmpl page during the merge
of #16594 - I am not entirely sure how this happened as the PR was correct.

This PR fixes the broken template.

Fix #18388

Signed-off-by: Andrew Thornton <[email protected]>
zeripath added a commit to zeripath/gitea that referenced this issue Jan 26, 2022
Backport go-gitea#18412

It appears that there was a broken merge of the edit.tmpl page during the merge
of go-gitea#16594 - I am not entirely sure how this happened as the PR was correct.

This PR fixes the broken template.

Fix go-gitea#18388

Signed-off-by: Andrew Thornton <[email protected]>
zeripath added a commit that referenced this issue Jan 26, 2022
Backport #18412

It appears that there was a broken merge of the edit.tmpl page during the merge
of #16594 - I am not entirely sure how this happened as the PR was correct.

This PR fixes the broken template.

Fix #18388

Signed-off-by: Andrew Thornton <[email protected]>
Chianina pushed a commit to Chianina/gitea that referenced this issue Mar 28, 2022
It appears that there was a broken merge of the edit.tmpl page during the merge
of go-gitea#16594 - I am not entirely sure how this happened as the PR was correct.

This PR fixes the broken template.

Fix go-gitea#18388

Signed-off-by: Andrew Thornton <[email protected]>
@go-gitea go-gitea locked and limited conversation to collaborators Apr 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants