File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -72,6 +72,13 @@ export interface OAuthClientProvider {
7272 * the authorization result.
7373 */
7474 codeVerifier ( ) : string | Promise < string > ;
75+
76+ /**
77+ * If defined, overrides the OAuth Protected Resource Metadata (RFC 9728).
78+ *
79+ * Implementations must verify the provider
80+ */
81+ validateProtectedResourceMetadata ?( metadata ?: OAuthProtectedResourceMetadata ) : Promise < void > ;
7582}
7683
7784export type AuthResult = "AUTHORIZED" | "REDIRECT" ;
@@ -109,11 +116,13 @@ export async function auth(
109116 } catch ( error ) {
110117 console . warn ( "Could not load OAuth Protected Resource metadata, falling back to /.well-known/oauth-authorization-server" , error )
111118 }
112- if ( resourceMetadata ) {
119+ if ( provider . validateProtectedResourceMetadata ) {
120+ await provider . validateProtectedResourceMetadata ( resourceMetadata ) ;
121+ } else if ( resourceMetadata ) {
113122 if ( resourceMetadata . authorization_servers && resourceMetadata . authorization_servers . length > 0 ) {
114123 authorizationServerUrl = resourceMetadata . authorization_servers [ 0 ] ;
115124 }
116- if ( resourceMetadata . resource && resourceMetadata . resource !== resource . href ) {
125+ if ( resourceMetadata . resource !== resource . href ) {
117126 throw new Error ( `Protected resource ${ resourceMetadata . resource } does not match expected ${ resource } ` ) ;
118127 }
119128 }
You can’t perform that action at this time.
0 commit comments