@guidofranco The feature is best applicable for authentication but there are authorization policies that you can configure to allow specific users to access your application.
Similarly, you can enforce these restrictions at the app registration level as well as shown in the official docs.
But for any other complex decision making that you may need, you will have to code the logic in - either in the same app or offload to a separate service that can make these checks across all your applications.