forked from Sunbird-Obsrv/obsrv-web-console
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #167 from Sanketika-Obsrv/keycloak_user_fix
#OBS-I529: Keycloak authentication and user creation fix
- Loading branch information
Showing
6 changed files
with
133 additions
and
23 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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { NextFunction, Request, Response } from "express"; | ||
import appConfig from "../../shared/resources/appConfig"; | ||
import { datasetServiceHttpInstance } from "../services/dataset"; | ||
|
||
const authenticationType = appConfig.AUTHENTICATION_TYPE; | ||
|
||
export default { | ||
name: 'datasetAuthInjector', | ||
handler: () => (request: any, response: Response, next: NextFunction) => { | ||
if (authenticationType === 'keycloak') { | ||
const keycloakToken = JSON.parse(request?.session['keycloak-token']); | ||
const access_token: string = keycloakToken.access_token; | ||
datasetServiceHttpInstance.defaults.headers['Authorization'] = `Bearer ${access_token}`; | ||
} else if (authenticationType === 'basic') { | ||
const jwtToken: string = request?.session?.token; | ||
datasetServiceHttpInstance.defaults.headers['Authorization'] = `Bearer ${jwtToken}`; | ||
} | ||
next(); | ||
} | ||
}; |
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