I want to implement Azure RBAC in a flask application. How should I do it?
Inside the web app, Users can assign and remove roles to other users.
I want to implement Azure RBAC in a flask application. How should I do it?
Inside the web app, Users can assign and remove roles to other users.
Copyright © 2021 Jogjafile Inc.
To achieve your requirement, firstly install
pip install Flask-OAuthlib
package as it is used for flask app authorization withOauth
(Azure RBAC).pip install Flask-OAuthlib
Now when it comes to implementation of RBAC in a flask app, follow below detailed steps.
Register a new app under Azure AD B2C and provide a flask web app URL in Redirect URL field. Once you registered it, create a client secret and store it with you.
Now go to
API permissions
and add the required Graph API permissions according to the requirement.In order to use Azure AD B2C in a flask app, the main thing you need to use is
oauth.remote_app
function in the python code which is given below.Output:
References:
Adding auth to a Flask App with Azure Active Directory and Oso for more relevant information.
Configuring authentication in a python app using Azure RBAC. And same will be applicable for flask web app as well.