Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: add oauth2 token exchange#11778

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

code-asher
Copy link
Member

@code-ashercode-asher commentedJan 23, 2024
edited
Loading

This adds a new identity provider package and hooks it into coderd routes along with some test refactoring. See commit messages for more details.

There is more work to be done (tracking in#11609) but I think this is fully featured enough to be merged in. All the routes are only accessible in dev mode.

It is getting pretty big, although 60% is HTML, tests, and generated code!

Blocked by:

Blocks:

@code-ashercode-asherforce-pushed theasher/oauth2-exchange-idp branch 5 times, most recently froma41182d to6a157e9CompareJanuary 24, 2024 02:12
@code-ashercode-asher marked this pull request as ready for reviewJanuary 24, 2024 02:42
@code-ashercode-asherforce-pushed theasher/oauth2-exchange-idp branch from6a157e9 tobecb1a3CompareJanuary 24, 2024 02:52
@code-ashercode-asherforce-pushed theasher/oauth2-exchange-idp branch frombecb1a3 to80fa017CompareJanuary 25, 2024 00:24
Copy link
Member

@EmyrkEmyrk left a comment

Choose a reason for hiding this comment

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

Consolidating and adding some hash function notes.

We should useuserpasword.Hash()

The user secret is currently 40 random characters, let's spruce that up.

  • Add acoder_ prefix so a random key in a text file is more easily recognized.
  • Add anid section of 10(?) random characters with a unique constraint.
  • Optionally... if you want to be really cool, add a 2 character checksum at the end, so if someone hand types this we can detect typos 😉

code-asher reacted with rocket emoji
@@ -233,7 +246,7 @@ func ParseCustomList[T any](parser *QueryParamParser, vals url.Values, def []T,
func parseQueryParam[T any](parser *QueryParamParser, vals url.Values, parse func(v string) (T, error), def T, queryParam string) (T, error) {
parser.addParsed(queryParam)
// If the query param is required and not present, return an error.
if parser.RequiredParams[queryParam] && (!vals.Has(queryParam)) {
if parser.RequiredParams[queryParam] && (!vals.Has(queryParam) || vals.Get(queryParam) == "") {
Copy link
Member

Choose a reason for hiding this comment

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

Why did we addvals.Get(queryParam) == ""? The empty string is a valid value for parsing params here. If it is not valid for your use case, we should solve it somewhere else.

I think this could break something 🤔

Suggested change
ifparser.RequiredParams[queryParam]&& (!vals.Has(queryParam)||vals.Get(queryParam)=="") {
ifparser.RequiredParams[queryParam]&& (!vals.Has(queryParam)) {

Copy link
MemberAuthor

@code-ashercode-asherFeb 6, 2024
edited
Loading

Choose a reason for hiding this comment

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

Yeah I had mixed feelings about this; it felt surprising to me that I could writeRequired("client_id") and it could come through empty. My thinking was that if I want to require a query param I also want a value.

I did check existing usages; it is used forreconnect on the terminal (which is invalid if blank) and forstart_time andend_time on an insights endpoint which also cannot be blank (it will fail to be parsed into a time).

But at the same time I see the distinction between required and empty. An empty query value is probably only useful as a boolean where the presence of the key meanstrue, and I could see requiring atrue for something like?acceptTerms or something like that before you can use the endpoint.

So let me rename this toRequiredNotEmpty, that will leave room forRequired if we do need that some day.

Emyrk reacted with thumbs up emoji
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Some new ones popped up after I merged main:template_id,workspace_id, andagent_id on some endpoints, they all make database queries with these values so I think they would just return "no rows" or a 404 or whatever, so this change will make it return "invalid query params, template_id is required" instead which I think is fair, but it does change the semantics a little from a 404 to a 400.

@code-ashercode-asher marked this pull request as draftFebruary 7, 2024 01:10
@code-asher
Copy link
MemberAuthor

code-asher commentedFeb 7, 2024
edited
Loading

Moved to a draft while I work on:

  1. Changing the hashing
  2. Adding the refresh flow

@code-ashercode-asherforce-pushed theasher/oauth2-exchange-db branch 3 times, most recently froma6b9de7 to3623f69CompareFebruary 9, 2024 03:23
@code-ashercode-asherforce-pushed theasher/oauth2-exchange-idp branch from765f71c tod530bb0CompareFebruary 9, 2024 03:24
@code-ashercode-asherforce-pushed theasher/oauth2-exchange-idp branch fromf862651 to911660aCompareFebruary 9, 2024 22:19
@code-ashercode-asherforce-pushed theasher/oauth2-exchange-db branch 3 times, most recently from0cf4f55 to6f03c33CompareFebruary 9, 2024 22:24
@code-ashercode-asherforce-pushed theasher/oauth2-exchange-idp branch from911660a toeb4ca9eCompareFebruary 9, 2024 22:25
@code-ashercode-asherforce-pushed theasher/oauth2-exchange-idp branch fromcd5fb8f to19fa030CompareFebruary 10, 2024 09:45
@code-ashercode-asherforce-pushed theasher/oauth2-exchange-idp branch frome6d7102 tocae4e61CompareFebruary 10, 2024 10:18
@code-asher
Copy link
MemberAuthor

Rebased, but only commits fromDelete some oidc helper comments onward are new. They should all be self-contained enough to review individually, if that appeals.

I really like the idea of a checksum but I have not implemented it yet. I was reading up some check digit algorithms and thinking maybe of using crc8 or something but got hit with decision paralysis so I am leaving it for the moment. 😓

@code-ashercode-asher marked this pull request as ready for reviewFebruary 10, 2024 10:18
@code-ashercode-asher mentioned this pull requestFeb 13, 2024
23 tasks
The referer check was not quite right either.
Copy link
Member

@EmyrkEmyrk left a comment

Choose a reason for hiding this comment

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

This is really good 👍.

Just 1 thing to address before I approve it inrefreshTokenGrant. Is there a leak of refresh codes?

code-asher reacted with heart emoji

// RevokeOAuth2ProviderApp completely revokes an app's access for the user.
func (c *Client) RevokeOAuth2ProviderApp(ctx context.Context, appID uuid.UUID) error {
res, err := c.Request(ctx, http.MethodDelete, "/login/oauth2/tokens", nil, func(r *http.Request) {
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if we should hardcode this to/login/oauth2/me/tokens for now to allow us supporting revoking other user's in the future.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Oh really good point, let me change it now real quick.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Oh right I had it here to have the post/delete paradigm on the same endpoint. Maybe I should actually move this back to/api/v2 since it is our own thing, not part of the whole oauth flow.

Copy link
Member

Choose a reason for hiding this comment

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

This is not an oauth2 spec endpoint right?

Eh just keep it here and comment that it is not oauth 2 spec. If you feel this has to be a static endpoint though, then just comment why it should be. I'll defer to your judgement

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Yup exactly, it is just our own thing and not part of the spec. I do not feel strongly about it, just felt kinda right to have posts and deletes on the same endpoint. Hmmm lemme give it some thought!

Copy link
Member

@EmyrkEmyrk left a comment

Choose a reason for hiding this comment

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

whoops meant to do request changes

@code-ashercode-asher merged commit0204adb intoasher/oauth2-exchange-dbFeb 20, 2024
@code-ashercode-asher deleted the asher/oauth2-exchange-idp branchFebruary 20, 2024 22:54
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsFeb 20, 2024
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@EmyrkEmyrkEmyrk approved these changes

Assignees

@code-ashercode-asher

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@code-asher@Emyrk

[8]ページ先頭

©2009-2025 Movatter.jp