-
Notifications
You must be signed in to change notification settings - Fork 175
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* cluster auth settings in cluster configuration * compose request decorator with cluster auth headers * update docs * simplify auth headers merging * lift returned value to Promise to simplify * missing tests * move docs * simplify test construction
- Loading branch information
1 parent
7b0a3ca
commit f680a95
Showing
9 changed files
with
185 additions
and
55 deletions.
There are no files selected for viewing
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Copyright 2017-2022 Allegro.pl | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { isNil } from "../../utils/general/general"; | ||
|
||
type ClusterAuthType = "http-basic"; | ||
|
||
interface BasicHttpClusterAuth { | ||
type: "http-basic"; | ||
username: string; | ||
password: string; | ||
} | ||
|
||
export type ClusterAuth = BasicHttpClusterAuth; | ||
|
||
export interface ClusterAuthJS { | ||
type: ClusterAuthType; | ||
username?: string; | ||
password?: string; | ||
} | ||
|
||
export function readClusterAuth(input?: ClusterAuthJS): ClusterAuth | undefined { | ||
if (isNil(input)) return undefined; | ||
switch (input.type) { | ||
case "http-basic": { | ||
const { username, password } = input; | ||
if (isNil(username)) throw new Error("ClusterAuth: username field is required for http-basic auth configuration"); | ||
if (isNil(password)) throw new Error("ClusterAuth: password field is required for http-basic auth configuration"); | ||
return { | ||
type: "http-basic", | ||
password, | ||
username | ||
}; | ||
} | ||
default: { | ||
throw new Error(`ClusterAuth: Unrecognized authorization type: ${input.type}`); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.