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

GitHub Authentication provider returns a different token type when connected to a CodeSpace in a browser #185915

Closed
alexweininger opened this issue Jun 22, 2023 · 4 comments
Assignees

Comments

@alexweininger
Copy link
Member

Does this issue occur when all extensions are disabled?: No, issue with extension

  • VS Code Version: 1.80.0-insider
  • OS Version: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.3

In a browser connected to a CodeSpace we receive "GitHub App user-to-server tokens" (prefixed with ghu_). In all other places I tested, we receive "OAuth access tokens" (prefixed by gho_) 1. The user-to-server tokens are created by GitHub Apps, whereas OAuth tokens are created by OAuth apps 2.

This causes issues because the tokens behave quite differently and have different, unique scoping systems. Also, if you try to request a new token with a user-to-server token (ghu) specific scope, the auth provider returns a gho token.

Steps to Reproduce:

It's easiest to reproduce this issue by using the Fugio extension.

  1. Connect to a CodeSpace in a browser-based VS Code instance.
  2. Run command "Fugio: Mint Token" via the palette.
  3. Select "GitHub"
  4. Select "Use custom value..."
  5. Enter repo workflow user:email read:user
image
  1. Select "Copy access token" and observe the token prefix.

Footnotes

  1. GitHub authentication token formats: https://github.blog/2021-04-05-behind-githubs-new-authentication-token-formats/

  2. Differences between GitHub Apps and OAuth apps https://docs.github.com/en/apps/oauth-apps/building-oauth-apps/differences-between-github-apps-and-oauth-apps

@TylerLeonhardt
Copy link
Member

Yeah this is expected. In the web, Codespaces supplies tokens from their GitHub App ahead of time, that are used by the extensions that we wanted to be already logged in when the Codespace loads. Any additional requests go through the OAuth flow.

Can I ask what behavior difference you're seeing that's causing you issues?

cc @joshaber @jkeech

@alexweininger
Copy link
Member Author

For us specifically, the Static Web Apps service isn't compatible with the GitHub App tokens. I think the weirdest part is that we're requesting a token with OAuth-specific scopes and we receive a GitHub App token with unknown scopes.

Our current workaround is to make another getSession call with a fake scope so that VS Code gives us a OAuth token.

@TylerLeonhardt
Copy link
Member

I'm not sure what I can do from the auth extension perspective. We likely need to figure out a way to get the SWA extension to play nice with the GitHub App tokens available in Codespaces...

@TylerLeonhardt TylerLeonhardt added the under-discussion Issue is under discussion for relevance, priority, approach label Jun 26, 2023
@TylerLeonhardt TylerLeonhardt added the authentication Issues with the Authentication platform label Dec 4, 2023
@TylerLeonhardt
Copy link
Member

This isn't something in our control. I think the SWA team needs to allow Codespaces GH Apps tokens.

@TylerLeonhardt TylerLeonhardt closed this as not planned Won't fix, can't repro, duplicate, stale Dec 14, 2023
@TylerLeonhardt TylerLeonhardt removed under-discussion Issue is under discussion for relevance, priority, approach authentication Issues with the Authentication platform labels Dec 14, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Jan 28, 2024
@aiday-mar aiday-mar added this to the December / January 2024 milestone Feb 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants