Skip to content

Commit

Permalink
[Fix][WRS-2106] Add support of "authorizationServerMetadata" to OAuth…
Browse files Browse the repository at this point in the history
…2ResourceOwner (#78)
  • Loading branch information
psamusev authored Nov 5, 2024
1 parent 572732d commit 0e2b399
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
{
"$schema": "https://json-schema.org/draft-07/schema",

"$defs": {
"AuthorizatoinServerMetadata": {
"type": "object",
"properties": {
"token_endpoint_auth_methods_supported": {
"type": "array",
"items": {
"type": "string",
"enum": ["client_secret_basic", "client_secret_post"]
}
}
},
"required": ["token_endpoint_auth_methods_supported"],
"additionalProperties": false
}
},
"type": "object",
"properties": {
"name": {
Expand All @@ -27,6 +42,9 @@
"bodyFormat": {
"type": "string",
"enum": ["applicationJson", "formUrlEncoded"]
},
"authorizationServerMetadata": {
"$ref": "#/$defs/AuthorizatoinServerMetadata"
}
},
"required": [
Expand Down
14 changes: 14 additions & 0 deletions src/connector-cli/resources/schemas/connector-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,20 @@
"bodyFormat": {
"type": "string",
"enum": ["applicationJson", "formUrlEncoded"]
},
"authorizationServerMetadata": {
"type": "object",
"properties": {
"token_endpoint_auth_methods_supported": {
"type": "array",
"items": {
"type": "string",
"enum": ["client_secret_basic", "client_secret_post"]
}
}
},
"required": ["token_endpoint_auth_methods_supported"],
"additionalProperties": false
}
},
"required": ["bodyFormat"],
Expand Down
2 changes: 1 addition & 1 deletion src/connector-cli/src/core/error-handling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export function withErrorHandlerAction(
} catch (err) {
if (err instanceof ExecutionError) {
error(err.message);
return;
process.exit(1);
}
throw err;
}
Expand Down
44 changes: 31 additions & 13 deletions src/connector-cli/src/core/types/gen-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ export interface ChiliToken {
}

export interface Oauth2AuthorizationCode {
authorizationServerMetadata: AuthorizationServerMetadata;
authorizationServerMetadata: Oauth2AuthorizationCodeAuthorizationServerMetadata;
clientId: string;
clientSecret: string;
name?: string;
scope?: string;
specCustomization?: SpecCustomization;
}

export interface AuthorizationServerMetadata {
export interface Oauth2AuthorizationCodeAuthorizationServerMetadata {
authorization_endpoint: string;
token_endpoint: string;
token_endpoint_auth_methods_supported: TokenEndpointAuthMethodsSupported[];
Expand Down Expand Up @@ -55,14 +55,19 @@ export interface Oauth2ClientCredentials {
}

export interface Oauth2ResourceOwnerPassword {
bodyFormat?: RequestContentType;
clientId: string;
clientSecret: string;
name?: string;
password: string;
scope?: string;
tokenEndpoint: string;
username: string;
authorizationServerMetadata?: Oauth2ResourceOwnerPasswordAuthorizationServerMetadata;
bodyFormat?: RequestContentType;
clientId: string;
clientSecret: string;
name?: string;
password: string;
scope?: string;
tokenEndpoint: string;
username: string;
}

export interface Oauth2ResourceOwnerPasswordAuthorizationServerMetadata {
token_endpoint_auth_methods_supported: TokenEndpointAuthMethodsSupported[];
}

export interface StaticKey {
Expand Down Expand Up @@ -101,7 +106,12 @@ export interface OAuth2AuthorizationCodeSpecCustomization {
}

export interface OAuth2ResourceOwnerPassword {
bodyFormat: RequestContentType;
authorizationServerMetadata?: OAuth2ResourceOwnerPasswordAuthorizationServerMetadata;
bodyFormat: RequestContentType;
}

export interface OAuth2ResourceOwnerPasswordAuthorizationServerMetadata {
token_endpoint_auth_methods_supported: TokenEndpointAuthMethodsSupported[];
}

export enum SupportedAuth {
Expand Down Expand Up @@ -326,14 +336,14 @@ const typeMap: any = {
{ json: "name", js: "name", typ: u(undefined, "") },
], false),
"Oauth2AuthorizationCode": o([
{ json: "authorizationServerMetadata", js: "authorizationServerMetadata", typ: r("AuthorizationServerMetadata") },
{ json: "authorizationServerMetadata", js: "authorizationServerMetadata", typ: r("Oauth2AuthorizationCodeAuthorizationServerMetadata") },
{ json: "clientId", js: "clientId", typ: "" },
{ json: "clientSecret", js: "clientSecret", typ: "" },
{ json: "name", js: "name", typ: u(undefined, "") },
{ json: "scope", js: "scope", typ: u(undefined, "") },
{ json: "specCustomization", js: "specCustomization", typ: u(undefined, r("SpecCustomization")) },
], false),
"AuthorizationServerMetadata": o([
"Oauth2AuthorizationCodeAuthorizationServerMetadata": o([
{ json: "authorization_endpoint", js: "authorization_endpoint", typ: "" },
{ json: "token_endpoint", js: "token_endpoint", typ: "" },
{ json: "token_endpoint_auth_methods_supported", js: "token_endpoint_auth_methods_supported", typ: a(r("TokenEndpointAuthMethodsSupported")) },
Expand All @@ -350,6 +360,7 @@ const typeMap: any = {
{ json: "tokenEndpoint", js: "tokenEndpoint", typ: "" },
], false),
"Oauth2ResourceOwnerPassword": o([
{ json: "authorizationServerMetadata", js: "authorizationServerMetadata", typ: u(undefined, r("Oauth2ResourceOwnerPasswordAuthorizationServerMetadata")) },
{ json: "bodyFormat", js: "bodyFormat", typ: u(undefined, r("RequestContentType")) },
{ json: "clientId", js: "clientId", typ: "" },
{ json: "clientSecret", js: "clientSecret", typ: "" },
Expand All @@ -359,6 +370,9 @@ const typeMap: any = {
{ json: "tokenEndpoint", js: "tokenEndpoint", typ: "" },
{ json: "username", js: "username", typ: "" },
], false),
"Oauth2ResourceOwnerPasswordAuthorizationServerMetadata": o([
{ json: "token_endpoint_auth_methods_supported", js: "token_endpoint_auth_methods_supported", typ: a(r("TokenEndpointAuthMethodsSupported")) },
], false),
"StaticKey": o([
{ json: "key", js: "key", typ: "" },
{ json: "name", js: "name", typ: u(undefined, "") },
Expand Down Expand Up @@ -389,8 +403,12 @@ const typeMap: any = {
{ json: "requestContentType", js: "requestContentType", typ: u(undefined, r("RequestContentType")) },
], false),
"OAuth2ResourceOwnerPassword": o([
{ json: "authorizationServerMetadata", js: "authorizationServerMetadata", typ: u(undefined, r("OAuth2ResourceOwnerPasswordAuthorizationServerMetadata")) },
{ json: "bodyFormat", js: "bodyFormat", typ: r("RequestContentType") },
], false),
"OAuth2ResourceOwnerPasswordAuthorizationServerMetadata": o([
{ json: "token_endpoint_auth_methods_supported", js: "token_endpoint_auth_methods_supported", typ: a(r("TokenEndpointAuthMethodsSupported")) },
], false),
"TokenEndpointAuthMethodsSupported": [
"client_secret_basic",
"client_secret_post",
Expand Down

0 comments on commit 0e2b399

Please sign in to comment.