Working towards OpenID - Connect
- Adding id_token support - Adding bearer token header support for client api auth
This commit is contained in:
@ -11,11 +11,11 @@ export function GetClientAuthMiddleware(checksecret = true, internal = false, ch
|
||||
try {
|
||||
let client_id = req.query.client_id || req.body.client_id;
|
||||
let client_secret = req.query.client_secret || req.body.client_secret;
|
||||
|
||||
if(!client_id && !client_secret && req.headers.authorization) {
|
||||
|
||||
if (!client_id && !client_secret && req.headers.authorization) {
|
||||
let header = req.headers.authorization;
|
||||
let [type, val] = header.split(" ");
|
||||
if(val) {
|
||||
if (val) {
|
||||
let str = Buffer.from(val, "base64").toString("utf-8");
|
||||
let [id, secret] = str.split(":");
|
||||
client_id = id;
|
||||
@ -53,10 +53,13 @@ export function GetClientApiAuthMiddleware(permissions?: string[]) {
|
||||
return async (req: Request, res: Response, next: NextFunction) => {
|
||||
try {
|
||||
const invalid_err = new RequestError(req.__("You are not logged in or your login is expired"), HttpStatusCode.UNAUTHORIZED);
|
||||
let token = req.query.access_token || req.headers.authorization;
|
||||
let token: string = req.query.access_token || req.headers.authorization;
|
||||
if (!token)
|
||||
throw invalid_err;
|
||||
|
||||
if (token.toLowerCase().startsWith("bearer "))
|
||||
token = token.substring(7);
|
||||
|
||||
let data: OAuthJWT;
|
||||
try {
|
||||
data = await validateJWT(token);
|
||||
|
Reference in New Issue
Block a user