summaryrefslogtreecommitdiffstats
path: root/sdnr/wt/odlux/framework/src/services
diff options
context:
space:
mode:
Diffstat (limited to 'sdnr/wt/odlux/framework/src/services')
-rw-r--r--sdnr/wt/odlux/framework/src/services/authenticationService.ts20
1 files changed, 19 insertions, 1 deletions
diff --git a/sdnr/wt/odlux/framework/src/services/authenticationService.ts b/sdnr/wt/odlux/framework/src/services/authenticationService.ts
index d3d62c566..cd8a93a53 100644
--- a/sdnr/wt/odlux/framework/src/services/authenticationService.ts
+++ b/sdnr/wt/odlux/framework/src/services/authenticationService.ts
@@ -26,7 +26,7 @@ type AuthTokenResponse = {
class AuthenticationService {
- public async authenticateUser(email: string, password: string, scope: string): Promise<AuthToken | null> {
+ public async authenticateUserOAuth(email: string, password: string, scope: string): Promise<AuthToken | null> {
const result = await requestRest<string>(`oauth2/token`, {
method: "POST",
headers: {
@@ -47,6 +47,24 @@ class AuthenticationService {
expires: (new Date().valueOf()) + (resultObj.expires_in * 1000)
} || null;
}
+
+ public async authenticateUserBasicAuth(email: string, password: string, scope: string): Promise<AuthToken | null> {
+ const result = await requestRest<string>(`restconf/modules`, {
+ method: "GET",
+ headers: {
+ 'Authorization': "Basic " + btoa(email + ":" + password)
+ },
+ }, false);
+ if (result) {
+ return {
+ username: email,
+ access_token: btoa(email + ":" + password),
+ token_type: "Basic",
+ expires: (new Date()).valueOf() + 2678400000 // 31 days
+ }
+ }
+ return null;
+ }
}
export const authenticationService = new AuthenticationService();