Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat: allow configurable username claim field in OIDC #5507

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

Merged
merged 5 commits into from
Jan 4, 2023

Conversation

janLo
Copy link
Contributor

@janLo janLo commented Dec 22, 2022

Gitlab does not set the preferred_username field.

Therefore, coder generates something from the user's email address, which is not very helpful. This allows the administrator to change the field used for the username (e.g. to "nickname")

@github-actions
Copy link

github-actions bot commented Dec 22, 2022

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@janLo janLo force-pushed the oidc-username-claim branch from 5f683fc to 415439b Compare December 22, 2022 15:13
@janLo
Copy link
Contributor Author

janLo commented Dec 22, 2022

I have read the CLA Document and I hereby sign the CLA

@janLo janLo force-pushed the oidc-username-claim branch from 415439b to 6c47ef8 Compare December 22, 2022 15:21
@janLo
Copy link
Contributor Author

janLo commented Dec 22, 2022

@whitney-coder as requested I tag you here. This would really help everyone trying to use gitlab as opened connect provider. As they use the nickname claim to publish the username: https://gitlab.com/gitlab-org/gitlab/-/blob/master/config/initializers/doorkeeper_openid_connect.rb#L35

@whitney-coder
Copy link
Contributor

@bpmct tagging you here to get your eyes/thoughts on this!

Copy link
Contributor

@coadler coadler left a comment

Choose a reason for hiding this comment

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

Looks good to me! You'll have to run make update-golden-files to update the CLI golden file.

cli/root_test.go Outdated
@@ -124,6 +124,7 @@ ExtractCommandPathsLoop:
require.NoError(t, err, "read golden file, run \"make update-golden-files\" and commit the changes")
// Remove CRLF newlines (Windows).
want = bytes.ReplaceAll(want, []byte{'\r', '\n'}, []byte{'\n'})
fmt.Printf(string(got))
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
fmt.Printf(string(got))

@janLo
Copy link
Contributor Author

janLo commented Dec 22, 2022

Oh that printf slipped through, I'll fix this as soon as I'm on my laptop again.

I just couldn't get this make target to run that's why I've manually created the change for the golden file.

Gitlab does not set the preferred_username field.

Therefore, coder generates something from the users email address, which
is not very helpful. This allows the administrator to change the field
used for the username (e.g. to "nickname")

Signed-off-by: Jan Losinski <[email protected]>
@janLo janLo force-pushed the oidc-username-claim branch from 6c47ef8 to d10b30f Compare December 23, 2022 07:52
@janLo
Copy link
Contributor Author

janLo commented Dec 23, 2022

@coadler I've removed the printf. If I try to generate the golden files I get this:

% make update-golden-files
--- FAIL: TestCommandHelp (0.00s)
    --- FAIL: TestCommandHelp/coder_--help (0.00s)
panic: testing: t.Setenv called after t.Parallel; cannot set environment variables in parallel tests [recovered]
        panic: testing: t.Setenv called after t.Parallel; cannot set environment variables in parallel tests

goroutine 9 [running]:
testing.tRunner.func1.2({0x1cc1fa0, 0x24e0b00})
        /home/losinski/.go_sdk/go1.20rc1/src/testing/testing.go:1525 +0x24e
testing.tRunner.func1()
        /home/losinski/.go_sdk/go1.20rc1/src/testing/testing.go:1528 +0x39f
panic({0x1cc1fa0, 0x24e0b00})
        /home/losinski/.go_sdk/go1.20rc1/src/runtime/panic.go:884 +0x213
testing.(*T).Setenv(0x1d81080?, {0xc0000610b0?, 0xc0000610b0?}, {0x0?, 0x0?})
        /home/losinski/.go_sdk/go1.20rc1/src/testing/testing.go:1415 +0x68
github.com/coder/coder/cli_test.TestCommandHelp.func1(0xc00044c820)
        /home/losinski/devel/coder/cli/root_test.go:92 +0x350
testing.tRunner(0xc00044c820, 0xc000fb2500)
        /home/losinski/.go_sdk/go1.20rc1/src/testing/testing.go:1575 +0x10b
created by testing.(*T).Run
        /home/losinski/.go_sdk/go1.20rc1/src/testing/testing.go:1628 +0x3ea
FAIL    github.com/coder/coder/cli      0.131s
FAIL
make: *** [Makefile:478: cli/testdata/.gen-golden] Fehler 1

@janLo
Copy link
Contributor Author

janLo commented Jan 4, 2023

@coadler is there anyhing I can do?

@coadler
Copy link
Contributor

coadler commented Jan 4, 2023

@janLo do you mind if I push to your branch to fix the CI failures?

@janLo
Copy link
Contributor Author

janLo commented Jan 4, 2023

@janLo do you mind if I push to your branch to fix the CI failures?

Not at all! Thank you!

@coadler coadler requested a review from a team as a code owner January 4, 2023 21:04
@coadler coadler requested review from jsjoeio and removed request for a team and jsjoeio January 4, 2023 21:04
@coadler coadler changed the title feat: allow users to set the username claim field in OIDC feat: allow configurable username claim field in OIDC Jan 4, 2023
@coadler coadler merged commit de0601d into coder:main Jan 4, 2023
@coadler
Copy link
Contributor

coadler commented Jan 4, 2023

Thanks! 🎉

@github-actions github-actions bot locked and limited conversation to collaborators Jan 4, 2023
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 this pull request may close these issues.

3 participants