mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-23 00:48:25 +00:00
Implemented backend call for restricting queries and adding audit logs
This commit is contained in:
parent
56b8fd42bc
commit
b099b82066
5 changed files with 18 additions and 30 deletions
|
|
@ -271,28 +271,6 @@ export const createQueryPanelSlice = (set, get) => ({
|
|||
|
||||
let dataQuery = {};
|
||||
|
||||
//for viewer, if query is restricted throw unauthorized error
|
||||
if (query.restricted) {
|
||||
setResolvedQuery(queryId, {
|
||||
isLoading: false,
|
||||
metadata: {
|
||||
response: {
|
||||
statusCode: 401,
|
||||
responseBody: 'Unauthorized access',
|
||||
},
|
||||
},
|
||||
response: {
|
||||
statusCode: 401,
|
||||
responseBody: 'Unauthorized access',
|
||||
},
|
||||
});
|
||||
onEvent('onDataQueryFailure', queryEvents);
|
||||
return {
|
||||
statusCode: 401,
|
||||
responseBody: 'Unauthorized access',
|
||||
};
|
||||
}
|
||||
|
||||
//for viewer we will only get the environment id from the url
|
||||
const { currentAppEnvironmentId, environmentId } = app;
|
||||
|
||||
|
|
@ -453,7 +431,7 @@ export const createQueryPanelSlice = (set, get) => ({
|
|||
|
||||
setResolvedQuery(queryId, {
|
||||
isLoading: false,
|
||||
...(query.kind === 'restapi'
|
||||
...(query.kind === 'restapi' || data.data.type === 'tj-401'
|
||||
? {
|
||||
metadata: data.metadata,
|
||||
request: data.data.requestObject,
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 7955b0c301128cfa995232b7039f2408cdee4be2
|
||||
Subproject commit 1ce85ca747c4b4bd01cccd7afc2d36d4e4eec364
|
||||
|
|
@ -14,7 +14,8 @@ export interface IDataQueriesUtilService {
|
|||
dataQuery: any,
|
||||
queryOptions: object,
|
||||
response: Response,
|
||||
environmentId?: string
|
||||
environmentId?: string,
|
||||
mode?: string
|
||||
): Promise<object>;
|
||||
|
||||
fetchServiceAndParsedParams(
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ export class DataQueriesService implements IDataQueriesService {
|
|||
dataQuery['options'] = options;
|
||||
}
|
||||
|
||||
return this.runAndGetResult(user, dataQuery, resolvedOptions, response, environmentId);
|
||||
return this.runAndGetResult(user, dataQuery, resolvedOptions, response, environmentId, mode);
|
||||
}
|
||||
|
||||
async runQueryForApp(user: User, dataQueryId: string, updateDataQueryDto: UpdateDataQueryDto, response: Response) {
|
||||
|
|
@ -159,12 +159,20 @@ export class DataQueriesService implements IDataQueriesService {
|
|||
dataQuery: DataQuery,
|
||||
resolvedOptions: object,
|
||||
response: Response,
|
||||
environmentId?: string
|
||||
environmentId?: string,
|
||||
mode?: string
|
||||
): Promise<object> {
|
||||
let result = {};
|
||||
|
||||
try {
|
||||
result = await this.dataQueryUtilService.runQuery(user, dataQuery, resolvedOptions, response, environmentId);
|
||||
result = await this.dataQueryUtilService.runQuery(
|
||||
user,
|
||||
dataQuery,
|
||||
resolvedOptions,
|
||||
response,
|
||||
environmentId,
|
||||
mode
|
||||
);
|
||||
} catch (error) {
|
||||
if (error.constructor.name === 'QueryError') {
|
||||
result = {
|
||||
|
|
|
|||
|
|
@ -63,7 +63,8 @@ export class DataQueriesUtilService implements IDataQueriesUtilService {
|
|||
dataQuery: any,
|
||||
queryOptions: object,
|
||||
response: Response,
|
||||
environmentId?: string
|
||||
environmentId?: string,
|
||||
mode?: string
|
||||
): Promise<object> {
|
||||
let result;
|
||||
const queryStatus = new DataQueryStatus();
|
||||
|
|
@ -320,7 +321,7 @@ export class DataQueriesUtilService implements IDataQueriesUtilService {
|
|||
return { service, sourceOptions, parsedQueryOptions };
|
||||
}
|
||||
|
||||
private getCurrentUserToken = (isMultiAuthEnabled: boolean, tokenData: any, userId: string, isAppPublic: boolean) => {
|
||||
protected getCurrentUserToken = (isMultiAuthEnabled: boolean, tokenData: any, userId: string, isAppPublic: boolean) => {
|
||||
if (isMultiAuthEnabled) {
|
||||
if (!tokenData || !Array.isArray(tokenData)) return null;
|
||||
return !isAppPublic
|
||||
|
|
|
|||
Loading…
Reference in a new issue