forked from opensearch-project/OpenSearch-Dashboards
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Bandini Bhopi <bandinib@amazon.com>
- Loading branch information
1 parent
75f0268
commit 7feec54
Showing
9 changed files
with
144 additions
and
6 deletions.
There are no files selected for viewing
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
36 changes: 36 additions & 0 deletions
36
src/plugins/data_source_management/common/auth_registry/authentication_methods_registry.ts
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,36 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
export interface AuthMethodUIElements { | ||
credentialForm: React.JSX.Element; | ||
credentialSourceOption: any; | ||
} | ||
|
||
export type IAuthenticationMethodRegistery = Omit< | ||
AuthenticationMethodRegistery, | ||
'registerAuthenticationMethod' | ||
>; | ||
|
||
export class AuthenticationMethodRegistery { | ||
private readonly authMethods = new Map<string, AuthMethodUIElements>(); | ||
/** | ||
* Register a authMethods with function to return credentials inside the registry. | ||
* Authentication Method can only be registered once. subsequent calls with the same method name will throw an error. | ||
*/ | ||
public registerAuthenticationMethod(name: string, authMethodUIElements: AuthMethodUIElements) { | ||
if (this.authMethods.has(name)) { | ||
throw new Error(`Authentication method '${name}' is already registered`); | ||
} | ||
this.authMethods.set(name, authMethodUIElements); | ||
} | ||
|
||
public getAllAuthenticationMethods() { | ||
return [...this.authMethods.values()]; | ||
} | ||
|
||
public getAuthenticationMethod(name: string) { | ||
return this.authMethods.get(name); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/plugins/data_source_management/common/auth_registry/index.ts
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,10 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
export { | ||
IAuthenticationMethodRegistery, | ||
AuthMethodUIElements, | ||
AuthenticationMethodRegistery, | ||
} from './authentication_methods_registry'; |
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
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