Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
switch to default authentication method support in config
  • Loading branch information
davidgamero committed Jan 19, 2022
commit 0c2b0ff25617f2554a5a07f85ff3a3dd9d19bcc1
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,7 @@ import { {{classname}} } from '..{{filename}}{{extensionForDeno}}';
@injectable()
{{/useInversify}}
export class {{classname}}RequestFactory extends BaseAPIRequestFactory {
private defaultSecurityAuthentication: SecurityAuthentication | undefined;

public setDefaultSecurityAuthentication(auth: SecurityAuthentication){
this.defaultSecurityAuthentication = auth;
}


{{#operation}}
/**
{{#notes}}
Expand Down Expand Up @@ -161,11 +156,15 @@ export class {{classname}}RequestFactory extends BaseAPIRequestFactory {
{{/hasAuthMethods}}
{{#authMethods}}
// Apply auth methods
authMethod = this.defaultSecurityAuthentication || _config.authMethods["{{name}}"]
authMethod = _config.authMethods["{{name}}"]
if (authMethod) {
await authMethod.applySecurityAuthentication(requestContext);
}
{{/authMethods}}
const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default
if (defaultAuth) {
await authMethod.applySecurityAuthentication(requestContext);
}

return requestContext;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ export class {{#lambda.pascalcase}}{{name}}{{/lambda.pascalcase}}Authentication
{{/authMethods}}

export type AuthMethods = {
"default"?: SecurityAuthentication,
{{#authMethods}}
"{{name}}"?: SecurityAuthentication{{^-last}},{{/-last}}
{{/authMethods}}
Expand All @@ -126,6 +127,7 @@ export type HttpBearerConfiguration = { tokenProvider: TokenProvider };
export type OAuth2Configuration = { accessToken: string };

export type AuthMethodsConfiguration = {
"default"?: SecurityAuthentication,
{{#authMethods}}
"{{name}}"?: {{#isApiKey}}ApiKeyConfiguration{{/isApiKey}}{{#isBasicBasic}}HttpBasicConfiguration{{/isBasicBasic}}{{#isBasicBearer}}HttpBearerConfiguration{{/isBasicBearer}}{{#isOAuth}}OAuth2Configuration{{/isOAuth}}{{^-last}},{{/-last}}
{{/authMethods}}
Expand All @@ -141,6 +143,7 @@ export function configureAuthMethods(config: AuthMethodsConfiguration | undefine
if (!config) {
return authMethods;
}
authMethods["default"] = config["default"]

{{#authMethods}}
if (config["{{name}}"]) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@ export class Observable{{classname}} {
this.responseProcessor = responseProcessor || new {{classname}}ResponseProcessor();
}

public setDefaultSecurityAuthentication(auth: SecurityAuthentication){
this.requestFactory.setDefaultSecurityAuthentication(auth);
}

{{#operation}}
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ export class Promise{{classname}} {
this.api = new Observable{{classname}}(configuration, requestFactory, responseProcessor);
}

public setDefaultSecurityAuthentication(auth: SecurityAuthentication){
this.api.setDefaultSecurityAuthentication(auth);
}

{{#operation}}
/**
{{#notes}}
Expand Down