Skip to content

Commit

Permalink
Merge pull request #289 from Sanketika-Obsrv/rbac-update
Browse files Browse the repository at this point in the history
#OBS-l339: druid proxy and rbac update
  • Loading branch information
HarishGangula authored Dec 2, 2024
2 parents 38b311d + a6fea9b commit 244a9f1
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
6 changes: 3 additions & 3 deletions api-service/src/middlewares/RBAC_middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ const checkAccess = (decoded: any, action: string, req: Request, res: Response)

const basicToken = (token: string, req: Request, res: Response, next: NextFunction) => {
try {
const decoded = jwt.verify(token, config.user_token_public_key);
const decoded = jwt.verify(token, config.user_token_public_key, { algorithms: ['RS256'] });

if (!decoded || !_.isObject(decoded)) {
return errorHandler(401, "Token verification failed or invalid token", req, res);
Expand Down Expand Up @@ -125,8 +125,8 @@ export default {
(req as any).userID = "SYSTEM";
return next();
}

const token = req.get("x-user-token");
const authHeader = req.headers['authorization'];
const token = authHeader && authHeader.split(' ')[1];
if (!token) {
return errorHandler(401, "No token provided", req, res);
}
Expand Down
3 changes: 2 additions & 1 deletion api-service/src/routes/DruidProxyRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ druidProxyRouter.post(/\/druid\/v2(.*)/, setDataToRequestObject("query.wrapper.n
druidProxyRouter.get(/\/druid\/v2(.*)/, setDataToRequestObject("query.wrapper.native.get"), onRequest({ entity: Entity.DruidProxy }), wrapperService.forwardNativeGet);
druidProxyRouter.delete("/druid/v2/:queryId", setDataToRequestObject("query.wrapper.native.delete"), onRequest({ entity: Entity.DruidProxy }), wrapperService.forwardNativeDel)
druidProxyRouter.get("/status", setDataToRequestObject("query.wrapper.status"), onRequest({ entity: Entity.DruidProxy }), wrapperService.nativeStatus)
druidProxyRouter.get("/health", setDataToRequestObject("api.health"), onRequest({ entity: Entity.DruidProxy }), healthService.checkDruidHealth)
druidProxyRouter.get("/health", setDataToRequestObject("api.health"), onRequest({ entity: Entity.DruidProxy }), healthService.checkDruidHealth)
druidProxyRouter.get(/\/druid\/coordinator(.*)/, setDataToRequestObject("query.wrapper.native.get"), onRequest({entity: Entity.DruidProxy}), wrapperService.forwardNativeGetDatasource)
16 changes: 16 additions & 0 deletions api-service/src/services/WrapperService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,22 @@ class WrapperService {
} catch (error: any) { this.errorHandler.handleError(req, res, next, error, false); }
};

public forwardNativeGetDatasource = async (
req: Request,
res: Response,
next: NextFunction
) => {
try {
const headers = req?.headers;
const url = req?.url;
const result = await axios.get(
`${config.query_api.druid.host}:${config.query_api.druid.port}${url}`,
{ headers }
);
ResponseHandler.flatResponse(req, res, result);
} catch (error: any) { this.errorHandler.handleError(req, res, next, error, false); }
};

public nativeStatus = async (
req: Request,
res: Response,
Expand Down

0 comments on commit 244a9f1

Please sign in to comment.