feat(core) Simplify authentication type (#3578)

*  Add generic auth type

*  Remove queryAuth

*  Remove bearer

*  Remove headerAuth

*  Remove basicAuth

*  Adjust tests

*  Small improvements

* 👕 Fix lint issue
This commit is contained in:
Jan Oberhauser
2022-06-26 15:55:51 -07:00
committed by GitHub
parent 1e4fd9e4df
commit 86721fc496
15 changed files with 207 additions and 281 deletions

View File

@@ -150,6 +150,16 @@ export interface IRequestOptionsSimplified {
qs: IDataObject;
}
export interface IRequestOptionsSimplifiedAuth {
auth?: {
username: string;
password: string;
};
body?: IDataObject;
headers?: IDataObject;
qs?: IDataObject;
}
export abstract class ICredentialsHelper {
encryptionKey: string;
@@ -191,40 +201,16 @@ export abstract class ICredentialsHelper {
export interface IAuthenticateBase {
type: string;
properties: {
[key: string]: string;
};
properties:
| {
[key: string]: string;
}
| IRequestOptionsSimplifiedAuth;
}
export interface IAuthenticateBasicAuth extends IAuthenticateBase {
type: 'basicAuth';
properties: {
userPropertyName?: string;
passwordPropertyName?: string;
};
}
export interface IAuthenticateBearer extends IAuthenticateBase {
type: 'bearer';
properties: {
tokenPropertyName?: string;
};
}
export interface IAuthenticateHeaderAuth extends IAuthenticateBase {
type: 'headerAuth';
properties: {
name: string;
value: string;
};
}
export interface IAuthenticateQueryAuth extends IAuthenticateBase {
type: 'queryAuth';
properties: {
key: string;
value: string;
};
export interface IAuthenticateGeneric extends IAuthenticateBase {
type: 'generic';
properties: IRequestOptionsSimplifiedAuth;
}
export type IAuthenticate =
@@ -232,10 +218,7 @@ export type IAuthenticate =
credentials: ICredentialDataDecryptedObject,
requestOptions: IHttpRequestOptions,
) => Promise<IHttpRequestOptions>)
| IAuthenticateBasicAuth
| IAuthenticateBearer
| IAuthenticateHeaderAuth
| IAuthenticateQueryAuth;
| IAuthenticateGeneric;
export interface IAuthenticateRuleBase {
type: string;