Skip to content

API to map auth server to auth provider #248775

Description

@TylerLeonhardt

Context

In MCP land, and general OAuth land, we resolve what kind auth an MCP server needs by resolving to some OAuth Server Metadata. The important stuff in this is:

/**
 * Metadata about an OAuth 2.0 Authorization Server.
 */
export interface IAuthorizationServerMetadata {
	/**
	 * REQUIRED. The authorization server's issuer identifier URL that uses https scheme and has no query or fragment components.
	 */
	issuer: string;

	/**
	 * URL of the authorization server's authorization endpoint.
	 * This is REQUIRED unless no grant types are supported that use the authorization endpoint.
	 */
	authorization_endpoint?: string;

	/**
	 * URL of the authorization server's token endpoint.
	 * This is REQUIRED unless only the implicit grant type is supported.
	 */
	token_endpoint?: string;

	/**
	 * OPTIONAL. URL of the authorization server's OAuth 2.0 Dynamic Client Registration endpoint.
	 */
	registration_endpoint?: string;

	/**
	 * RECOMMENDED. JSON array containing a list of the OAuth 2.0 scope values supported.
	 */
	scopes_supported?: string[];

	/**
	 * REQUIRED. JSON array containing a list of the OAuth 2.0 response_type values supported.
	 */
	response_types_supported: string[];
}

From this, we plan on mapping issuers to auth providers. So for example, if we see an issuer like so:

https://github.com/login/oauth

we will use the github auth provider.

microsoft is where it gets interesting... because technically it is N issuers all it one based on the path of issuer.

https://login.microsoftonline.com/common/v2.0
https://login.microsoftonline.com/organizations/v2.0
https://login.microsoftonline.com/consumers/v2.0
https://login.microsoftonline.com/SOME_TENANT_ID/v2.0

These are all valid issuers. By default, VS Code uses organizations, but you can override it with a secret scope: VSCODE_TENANT:<value> so like VSCODE_TENANT:common or VSCODE_TENANT:<guid>.

The issuer is then used to make urls like:

https://login.microsoftonline.com/organizations/v2.0/authorize

which is the login page you see in your browser.
and

https://login.microsoftonline.com/organizations/v2.0/token

which is what you use to get a token after your browser redirects back to VS Code with a code.

Proposal

Option 1: Leaning in to VSCODE_TENANT

We have a resolveMcpAuthenticationScopes which is passed in the authorizationServer (aka issuer) and the scopes (aka scopes_supported)

declare module 'vscode' {
	export interface AuthenticationProvider {
		resolveMcpAuthenticationScopes?(authorizationServer: Uri, scopes: string[], token: CancellationToken): ProviderResult<string[]>;
	}
}

This will resolve the correct scopes. So:

  • issuer: https://login.microsoftonline.com/consumers/v2.0
  • ["api://foo/bar"]
    resolves to:
["api://foo/bar", "VSCODE_TENANT:consumers"]

Then the Microsoft auth provider will have the correct scopes to build the request.

Option 2: Making tenant first class

This is more work but maybe the direction we want to go...

	export interface AuthenticationProviderOptions {
		/**
		 * When specified, the caller of `getSession` will be able to override the issuer URL used to
		 * authenticate the user.
		 */
		readonly supportsIssuerOverride?: boolean;
	}

	export interface AuthenticationProviderSessionOptions {
		/**
		 * When specified, the authentication provider will use the provided issuer URL to
		 * authenticate the user. This is only used when a provider `supportsIssuerOverride` is set to true
		 */
		issuer?: Uri;
	}

	export interface AuthenticationGetSessionOptions {
		/**
		 * When specified, the authentication provider will use the provided issuer URL to
		 * authenticate the user. This is only used when a provider `supportsIssuerOverride` is set to true
		 */
		issuer?: Uri;
	}

and then we implement this in the Microsoft auth provider where the tenant is extracted from issuer and used as a replacement for VSCODE_TENANT.

Session provenance

Authentication providers that can issue sessions from more than one authorization server also need to report which server issued a returned session. Add the following API to the authIssuers proposal:

export interface AuthenticationSession {
	/**
	 * The authorization server that issued this session, when provided by the authentication provider.
	 * This identifies the OAuth server, not a REST API endpoint or resource audience.
	 */
	readonly authorizationServer?: Uri;
}

This lets consumers use the selected session authorization server instead of inferring it from provider configuration. Implemented by #337846.

Activity

  1. added this to the May 2025 milestone on May 13, 2025
  2. added
    feature-request
    authentication
    on May 13, 2025
  3. jrieken commented on May 13, 2025

    @jrieken
    Contributor

    I don't understand much of this but option 1 cannot be right

  4. TylerLeonhardt commented on May 13, 2025

    @TylerLeonhardt
    MemberAuthor

    From API sync: we go with Option 2... we need to figure out a good way to have an Auth Provider decide if it supports an issuer...

  5. added
    unreleased
    on May 14, 2025
  6. added
    insiders-released
    and removed
    unreleased
    on May 15, 2025
  7. 10 remaining items

  8. changed the title [-]API to map issuer to auth provider[/-] [+]API to map auth server to auth provider[/+] on Jun 7, 2025
  9. vikhyatprabhu commented on Jun 19, 2025

    @vikhyatprabhu

    Is the dynamic client registration mandatory to be supported by the authorization server? I was trying to write an extension which contributes an authentication provider and it was able to login into that provider and already has the session and the access token. The mcp server which provides the details of the same authorization server in the /.well-known/oauth-protected-resource or /.well-known/oauth-authorization-server, but VS Code always tries to do the dynamic client registration and fails . Used the proposed api https://code.visualstudio.com/updates/v1_101#_authentication-providers-supported-authorization-servers-for-mcp and followed the steps mentioned. Am I missing something?

    As far as I know , even github does not support dynamic client registration but it works and asks for using the authentication when I use the remote github MCP server . I have spent considerable time reading the github authentication extension code and did not find anything that I am doing different

  10. TylerLeonhardt commented on Jun 19, 2025

    @TylerLeonhardt
    MemberAuthor

    DCR is required for MCP auth using any authorization server that does not map to an AuthenticationProvider. The API that this issue talks about is how you make that association which lifts the requirement of DCR. In other words, this API delegates auth to a registered AuthenticationProvider which has a client id already.

  11. vikhyatprabhu commented on Jun 20, 2025

    @vikhyatprabhu

    I understand that. By client id do you mean it has to be registered with VS Code? As I said I have written an extension which provides an AuthenticationProvider, which already is capable of getting a session and token, Clientid and secret are gotten from the user and stored, and my MCP server returns the same Authorization server but still VS Code is not able to connect to the server, only warning I see is wrt dynamic client registration. I see that it does hit the /.well-known/oauth-authorization-server and gets details but later doesn't do anything

  12. TylerLeonhardt commented on Jun 20, 2025

    @TylerLeonhardt
    MemberAuthor

    By client id do you mean it has to be registered with VS Code?

    No. Client id with the authorization server. We have already registered VS Code with GitHub so it holds on its a client id in the Auth Provider for GitHub.

    So in your extension, are you:

    If you do all these things, it should work. If it still doesn't work, I'll need a repro extension.

  13. modified the milestones: 1.111.0, On Deck on Mar 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

api-proposalauthenticationfeature-request

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions