-
Notifications
You must be signed in to change notification settings - Fork 58
refactor: authorize migrated legacy API operations #273
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: security/trusted-principal
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -119,6 +119,11 @@ export interface IAPIEngine { | |
| */ | ||
| startEvent(query, elementId, data: {}, user: ISecureUser, options?:IEngineOptions): Promise<IExecution>; | ||
|
|
||
| /** | ||
| * Retrieve one execution after applying the caller's item-level authorization. | ||
| */ | ||
| get(query, user: ISecureUser): Promise<IExecution>; | ||
|
|
||
|
|
||
| /** | ||
| * | ||
|
|
@@ -131,7 +136,7 @@ export interface IAPIEngine { | |
| * @param inputData | ||
| * | ||
| */ | ||
| restart(itemQuery, data:any,userName, options?) :Promise<IExecution>; | ||
| restart(itemQuery, data:any, user: ISecureUser, options?) :Promise<IExecution>; | ||
|
|
||
| /** | ||
| * upgrade running instances with the latest revised bpmn model | ||
|
|
@@ -150,6 +155,10 @@ export interface IAPIEngine { | |
|
|
||
|
|
||
| export interface IAPIData { | ||
| /** | ||
| * Run a cursor-based instance query after qualifying its filter for the caller. | ||
| */ | ||
| find(options, user: ISecureUser); | ||
| /** | ||
| returns list of `User Tasks` that the user has access to | ||
|
|
||
|
|
@@ -261,9 +270,17 @@ class APIEngine extends APIComponent implements IAPIEngine { | |
| } | ||
| public async startEvent(query, elementId, data = {}, user?: ISecureUser, options:IEngineOptions = {}): Promise<IExecution> { | ||
| user=this.getUser(user); | ||
| query = user.qualifyItems(query); | ||
| return await this.server.engine.startEvent(query, elementId, data,user.userName,options); | ||
| } | ||
| public async get(query, user?: ISecureUser): Promise<IExecution> { | ||
| user=this.getUser(user); | ||
| query = user.qualifyItems(query); | ||
| return await this.server.engine.get(query); | ||
| } | ||
| public async restart(itemQuery, data:any,user:ISecureUser, options={}) :Promise<IExecution> { | ||
| user=this.getUser(user); | ||
| itemQuery = user.qualifyItems(itemQuery); | ||
| return await this.server.engine.restart(itemQuery, data,user.userName, options); | ||
|
|
||
| } | ||
|
|
@@ -272,6 +289,11 @@ class APIEngine extends APIComponent implements IAPIEngine { | |
| } | ||
| } | ||
| class APIData extends APIComponent { | ||
| public async find(options: any = {}, user?: ISecureUser) { | ||
| user=this.getUser(user); | ||
| options = { ...options, filter: user.qualifyInstances(options.filter || {}) }; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When a non-admin calls Useful? React with 👍 / 👎. |
||
| return await this.server.dataStore.find(options); | ||
| } | ||
| public async getPendingUserTasks(query, user?: ISecureUser): Promise<IItemData[]> { | ||
|
|
||
| query['items.status'] = 'wait'; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When a normal non-admin passes the string instance ID expected by
Engine.startEvent, this line sends that primitive throughSecureUser.qualifyItems, whose implementation assigns$orand optionallytenantIdproperties to its argument. In ESM strict mode this throwsTypeError: Cannot create property '$or' on string ..., so authenticated non-admin callers can no longer start secondary events. Build and qualify an instance query, resolve its ID, and pass that ID to the engine instead.Useful? React with 👍 / 👎.