Link to home
Start Free TrialLog in
Avatar of Software Programmer
Software Programmer

asked on

How to provide access or grant based on custom conditions

Assume i want to provide grant an user based on certain conditions not based on roles or permissions or anything.

Assume a user hits the url /getAllOrders. i need to give access if satisfies certain conditions.

In that case, i am not sure how to do it. I checked and come across AccessDecisionVoter and not sure whether it will be suitable for it and also don't know how to implement it.

can someone suggest whethere AccessDecisionVoter would be the right option ?
looking for working sample code snippet which uses AccessDecisionVoter

Thanks.
SOLUTION
Avatar of Andrei Rodionov
Andrei Rodionov
Flag of Russian Federation image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Avatar of girionis
girionis
Flag of Greece image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Software Programmer
Software Programmer

ASKER

Condition is

User status should be active
User should be part of a specific group
User date should falls between certain condition
User should not have used more than the actual limit
etc.,
If you use a WebSecurityConfigurerAdapter  you should be fine.
Can u please help me with a sample code snippet for the above?