forked from spraakbanken/korp-frontend
-
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.
- Loading branch information
Showing
12 changed files
with
255 additions
and
248 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
- CQP queries | ||
- CorpusListing | ||
- `$rootScope` | ||
- Auth module | ||
|
||
### Changed | ||
|
||
|
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 was deleted.
Oops, something went wrong.
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,39 @@ | ||
/** @format */ | ||
import statemachine from "@/statemachine" | ||
import settings from "@/settings" | ||
import { AuthModule } from "./auth.types" | ||
|
||
function findAuthModule(): AuthModule | undefined { | ||
const authModuleName = settings["auth_module"]?.["module"] || settings["auth_module"] | ||
if (authModuleName == "federated_auth") { | ||
return require("./federatedauth/fed_auth") | ||
} | ||
if (authModuleName == "basic_auth" || authModuleName == undefined) { | ||
// load the default athentication | ||
return require("./basic_auth") | ||
} | ||
|
||
// must be a custom auth module | ||
try { | ||
return require("custom/" + authModuleName) | ||
} catch (error) { | ||
console.log("Auth module not available: ", authModule) | ||
} | ||
} | ||
|
||
const authModule = findAuthModule() | ||
|
||
export async function init(): Promise<boolean> { | ||
const loggedIn = await authModule.init() | ||
statemachine.send(loggedIn ? "USER_FOUND" : "USER_NOT_FOUND") | ||
return loggedIn | ||
} | ||
|
||
export const initAngular = authModule.initAngular | ||
export const login = authModule.login | ||
export const logout = authModule.logout | ||
export const getCredentials = authModule.getCredentials | ||
export const isLoggedIn = authModule.isLoggedIn | ||
export const getUsername = authModule.getUsername | ||
export const getAuthorizationHeader = authModule.getAuthorizationHeader | ||
export const hasCredential = authModule.hasCredential |
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,25 @@ | ||
/** @format */ | ||
|
||
import { IModule } from "angular" | ||
|
||
export type AuthModule = { | ||
/** | ||
* Check if logged in. | ||
* This is called before Angular app is initialized. | ||
*/ | ||
init: () => boolean | Promise<boolean> | ||
/** Initialize in Angular context (add login form components etc) */ | ||
initAngular: (korpApp: IModule) => void | ||
/** Trigger interactive authentication workflow */ | ||
login: Function | ||
/** Trigger logout */ | ||
logout: () => void | ||
/** Get headers to include in API requests */ | ||
getAuthorizationHeader: () => Record<string, string> | ||
/** Check if user has access to a given corpus */ | ||
hasCredential: (corpusId: string) => boolean | ||
/** Get corpus ids the user has access to */ | ||
getCredentials: () => string[] | ||
getUsername: () => string | ||
isLoggedIn: () => boolean | ||
} |
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,15 @@ | ||
/** @format */ | ||
import { Creds } from "@/local-storage" | ||
|
||
export type AuthState = { | ||
loginObj?: Creds | ||
} | ||
|
||
export type LoginResponseData = { | ||
corpora: string[] | ||
} | ||
|
||
export type AuthModuleOptions = { | ||
show_remember?: boolean | ||
default_value_remember?: boolean | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.