Skip to content
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

The following policy rules failed: [\"ExpirationRule\"]" #66

Closed
2 tasks done
ozbillwang opened this issue Oct 22, 2024 · 8 comments · May be fixed by #67
Closed
2 tasks done

The following policy rules failed: [\"ExpirationRule\"]" #66

ozbillwang opened this issue Oct 22, 2024 · 8 comments · May be fixed by #67
Assignees
Labels
bug Something isn't working

Comments

@ozbillwang
Copy link

ozbillwang commented Oct 22, 2024

Welcome

Description of the problem

With latest release, I can list role now.

$ export PIM_TOKEN=xxxx

$ az-pim-cli list role
== Azure Subscrioption 1 ==
	 - Groups Administrator
	 - User Administrator
	 - Application Administrator
	 - Security Reader

But when I try to activate the role, I got error "The following policy rules failed: [\"ExpirationRule\"]"

$ az-pim-cli activate role -n "Azure Subscrioption 1"
2024/10/23 10:09:53 Activating role 'Groups Administrator' for Entra role 'Azure Subscrioption 1' with reason 'config' (ticket:  [])
2024/10/23 10:09:57 The upstream API responded with status 400 Bad Request: {"error":{"code":"RoleAssignmentRequestPolicyValidationFailed","message":"The following policy rules failed: [\"ExpirationRule\"]"}}

Version of az-pim-cli

$ az-pim-cli version
az-pim-cli version (devel) (built with go1.22.4 from (ec7738f7f35898ed35c47c7f24e643e45042bc80, modified: false, mod sum: "") on 2024-10-21T11:33:18Z)

Configuration

export PIM_TOKEN=xxxx

Go environment

$ go version && go env
# paste output here

Output of command

# paste output here
# make sure to sensor any confidential output

Validation

  • Yes, I've included all information above (version, config, etc.).
@ozbillwang ozbillwang added the bug Something isn't working label Oct 22, 2024
@ozbillwang
Copy link
Author

Could we have an extra parameter "-d" or "--debug" to enable debug for any sub-commands when facing issues?

@netr0m
Copy link
Owner

netr0m commented Oct 23, 2024

My initial guess is that this resource requires a limited window of activation (default is 480 min, i.e. 8 hours). Could you retry with the parameter --duration <MINUTES>, e.g. --duration 30, and see if that helps?

From the help message:

  -d, --duration int           Duration in minutes that the role should be activated for (default 480)

Edit:

Based on Common errors returned by Azure Privileged Identity Management API, it seems that the error code XX is indeed due to a limitation in the maximum duration for a given role activation:

The ScheduleInfo specified in the request exceeds the maximum allowed duration

Try lowering the duration (e.g. --duration 30), and it should be resolved.

@netr0m
Copy link
Owner

netr0m commented Oct 23, 2024

Could we have an extra parameter "-d" or "--debug" to enable debug for any sub-commands when facing issues?

I'm working on an improved logging solution with this goal in mind. Stay tuned!

@netr0m netr0m self-assigned this Oct 23, 2024
@ozbillwang
Copy link
Author

ozbillwang commented Oct 23, 2024

Try lowering the duration (e.g. --duration 30), and it should be resolved.

Thanks, it works after add -d 30.

And I test with -d 480, it shows the error The following policy rules failed: [\"ExpirationRule\"]" again.

After manually check in Azure Console, I found the reason is, in our company, the max Duration is 6 hours ( 360 mins) , maybe that's the reason , it is failed with 480

@ozbillwang
Copy link
Author

ozbillwang commented Oct 23, 2024

Another problem with role

When I run the command without -r , it only activates the first role.

Is this the design?

If I need activate the rest, I have to run as command

az-pim-cli activate role -n "Azure Subscrioption 1" -r "Application Administrator" -d 60

But got a new issue The following policy rules failed: [\"TicketingRule\"]"

2024/10/23 22:38:01 Activating role 'Application Administrator' for Entra role 'Azure Subscrioption 1' with reason 'config' (ticket:  [])
2024/10/23 22:38:15 The upstream API responded with status 400 Bad Request: {"error":{"code":"RoleAssignmentRequestPolicyValidationFailed","message":"The following policy rules failed: [\"TicketingRule\"]"}}

Update

for below roles:

	 - Groups Administrator
	 - User Administrator
	 - Application Administrator
	 - Security Reader

I am fine to activate the rest 3, except role of Application Administrator with error The following policy rules failed: [\"TicketingRule\"]"

ozbillwang added a commit to ozbillwang/az-pim-cli that referenced this issue Oct 23, 2024
ozbillwang pushed a commit to ozbillwang/az-pim-cli that referenced this issue Oct 23, 2024
@ozbillwang
Copy link
Author

I have fixed the issue by add -T

az-pim-cli activate role -n "Azure Subscrioption 1" -r "Application Administrator" -T "ticket" -d 30

ozbillwang pushed a commit to ozbillwang/az-pim-cli that referenced this issue Oct 23, 2024
@netr0m
Copy link
Owner

netr0m commented Nov 5, 2024

Could we have an extra parameter "-d" or "--debug" to enable debug for any sub-commands when facing issues?

Hi @ozbillwang ,

I have now implemented a --debug flag to ease the process of troubleshooting (as part of #68). It is included in release v1.4.0

@ozbillwang
Copy link
Author

Could we have an extra parameter "-d" or "--debug" to enable debug for any sub-commands when facing issues?

Hi @ozbillwang ,

I have now implemented a --debug flag to ease the process of troubleshooting (as part of #68). It is included in release v1.4.0

Thanks, with --debug I got more information now.

netr0m pushed a commit to ozbillwang/az-pim-cli that referenced this issue Nov 6, 2024
netr0m pushed a commit to ozbillwang/az-pim-cli that referenced this issue Nov 6, 2024
netr0m pushed a commit to ozbillwang/az-pim-cli that referenced this issue Nov 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants