Skip to content

Make the --github-auth flag work for extensions #48

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 1 commit into from
Mar 1, 2022
Merged

Make the --github-auth flag work for extensions #48

merged 1 commit into from
Mar 1, 2022

Conversation

code-asher
Copy link
Member

@code-asher code-asher commented Mar 1, 2022

I was hoping the existing --github-auth flag would just work but it did not. Extensions seems to use a completely different credential entry for some reason so I have it inserting one that matches. I tested the pull request extension and GitLens.

There will be a companion PR shortly to make this work with code-server.

I am very unsure as to whether this is the right way to handle it.

Copy link

@jsjoeio jsjoeio left a comment

Choose a reason for hiding this comment

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

This are the kind of nuance things where I think, "How did Asher figure this out? 😅"

Nice work though! I appreciate the set of comments and how small this change is. Can't wait for patches.

Comment on lines -449 to +513
*
*
Copy link

Choose a reason for hiding this comment

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

Was this intentional?

Copy link
Member Author

@code-asher code-asher Mar 1, 2022

Choose a reason for hiding this comment

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

Ah it kind of was intentional in that I did see my editor had done this but for some reason it did not occur to me to skip committing this. Gonna remove to not needlessly increase the patch size.

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually looks like it is our own comment so I will go ahead and leave it.

* read:user.
* @author coder
*/
scopes: [['read:user', 'user:email', 'repo'], ['user:email'], ['repo']]
Copy link

Choose a reason for hiding this comment

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

❓ How come they have to be duplicated like this? I would think it would be enough to do:

Suggested change
scopes: [['read:user', 'user:email', 'repo'], ['user:email'], ['repo']]
scopes: [['read:user'], ['user:email'], ['repo']]

Copy link
Member Author

Choose a reason for hiding this comment

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

Yup, I thought so too but the scopes have to match exactly. So if an extension wants ['repo'] but the token offers both ['repo', 'read:user'] then it will not match.

You can see here they do a strict equals on the scopes array:

const finalSessions = scopes
? sessions.filter(session => arrayEquals([...session.scopes].sort(), scopes.sort()))
: sessions;

It does feel like a bug so maybe we should patch this instead but idk.

Copy link

Choose a reason for hiding this comment

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

AH...that make sense. Thanks for explaining. When we get to patches, I will see if it's a bug and we can raise upstream.

@code-asher code-asher merged commit 0fd21e4 into coder:main Mar 1, 2022
@code-asher code-asher deleted the github-auth branch March 1, 2022 18:48
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.

2 participants