-
Notifications
You must be signed in to change notification settings - Fork 360
[Agent] Allow 'AGENT - ADMIN' to access Agent Cards #5629
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ee18495
[Agent] New codeunit with utilities for system permissions
qutreson fbb8b4a
[Agent] Allow Agent Admin to acess agent cards
qutreson 7fa2af5
Code review
qutreson 2b6a2ac
Rename
qutreson 10e76f8
Add inherent permissions and entitlements
qutreson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
src/System Application/App/Agent/Permissions/AgentSystemPermissions.Codeunit.al
This file contains hidden or 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,45 @@ | ||
| // ------------------------------------------------------------------------------------------------ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. See License.txt in the project root for license information. | ||
| // ------------------------------------------------------------------------------------------------ | ||
|
|
||
| namespace System.Agents; | ||
|
|
||
| codeunit 4317 "Agent System Permissions" | ||
| { | ||
| InherentEntitlements = X; | ||
| InherentPermissions = X; | ||
|
|
||
| /// <summary> | ||
| /// Gets whether the current user has permissions to manage all agents. | ||
| /// </summary> | ||
| /// <returns>True if the user has permissions to manage all agents, false otherwise.</returns> | ||
| [Scope('OnPrem')] | ||
| procedure CurrentUserHasCanManageAllAgentsPermission(): Boolean | ||
qutreson marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| begin | ||
| exit("Agent System Permissions Impl.".CurrentUserHasCanManageAllAgentsPermission()); | ||
| end; | ||
|
|
||
| /// <summary> | ||
| /// Gets whether the current user has permissions to troubleshoot the execution of agent tasks. | ||
| /// </summary> | ||
| /// <returns>True if the user has troubleshoot permissions, false otherwise.</returns> | ||
| [Scope('OnPrem')] | ||
| procedure CurrentUserHasTroubleshootAllAgents(): Boolean | ||
| begin | ||
| exit("Agent System Permissions Impl.".CurrentUserHasTroubleshootAllAgents()); | ||
| end; | ||
|
|
||
| /// <summary> | ||
| /// Gets whether the current user has permissions to create custom agents. | ||
| /// </summary> | ||
| /// <returns>True if the user has create permissions, false otherwise.</returns> | ||
| [Scope('OnPrem')] | ||
| procedure CurrentUserHasCanCreateCustomAgent(): Boolean | ||
qutreson marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| begin | ||
| exit("Agent System Permissions Impl.".CurrentUserHasCanCreateCustomAgent()); | ||
| end; | ||
|
|
||
| var | ||
| "Agent System Permissions Impl.": Codeunit "Agent System Permissions Impl."; | ||
| } | ||
41 changes: 41 additions & 0 deletions
41
src/System Application/App/Agent/Permissions/Internal/AgentSystemPermissionsImpl.Codeunit.al
This file contains hidden or 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,41 @@ | ||
| // ------------------------------------------------------------------------------------------------ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. See License.txt in the project root for license information. | ||
| // ------------------------------------------------------------------------------------------------ | ||
|
|
||
| namespace System.Agents; | ||
|
|
||
| using System.Security.AccessControl; | ||
| using System.Security.User; | ||
|
|
||
| codeunit 4318 "Agent System Permissions Impl." | ||
| { | ||
| Access = Internal; | ||
| InherentEntitlements = X; | ||
| InherentPermissions = X; | ||
|
|
||
| procedure CurrentUserHasCanManageAllAgentsPermission(): Boolean | ||
| begin | ||
| exit(CurrentUserHasExecuteSystemPermission(9665)); // "Configure All Agents" | ||
| end; | ||
|
|
||
| procedure CurrentUserHasTroubleshootAllAgents(): Boolean | ||
| begin | ||
| exit(CurrentUserHasExecuteSystemPermission(9666)); // "Troubleshoot All Agents" | ||
| end; | ||
|
|
||
| procedure CurrentUserHasCanCreateCustomAgent(): Boolean | ||
| begin | ||
| // exit(CurrentUserHasExecuteSystemPermission(9667)); // "Create Custom Agent", not supported yet. | ||
| exit(false); | ||
| end; | ||
|
|
||
| local procedure CurrentUserHasExecuteSystemPermission(PermissionId: Integer): Boolean | ||
| var | ||
| TempPermission: Record "Expanded Permission" temporary; | ||
| UserPermissions: Codeunit "User Permissions"; | ||
| begin | ||
| TempPermission := UserPermissions.GetEffectivePermission(TempPermission."Object Type"::System, PermissionId); | ||
| exit(TempPermission."Execute Permission" = TempPermission."Execute Permission"::Yes); | ||
| end; | ||
| } |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.