diff options
author | Frederick Muriuki Muriithi | 2023-09-22 09:36:02 +0300 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2023-09-26 03:44:33 +0300 |
commit | ac76839f1cadbbc647c9772b3fdd4d496587b400 (patch) | |
tree | 7501622b2e1ea675c74c0b4ef7c3b7c06aa69920 /gn_auth/auth/authorisation/resources/system/views.py | |
parent | d57d13f3b82b5c981c4cadf0b74a0583a1535250 (diff) | |
download | gn-auth-ac76839f1cadbbc647c9772b3fdd4d496587b400.tar.gz |
Initialise package to handle resources of type "system".
Diffstat (limited to 'gn_auth/auth/authorisation/resources/system/views.py')
-rw-r--r-- | gn_auth/auth/authorisation/resources/system/views.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/gn_auth/auth/authorisation/resources/system/views.py b/gn_auth/auth/authorisation/resources/system/views.py new file mode 100644 index 0000000..70e28d6 --- /dev/null +++ b/gn_auth/auth/authorisation/resources/system/views.py @@ -0,0 +1,20 @@ +"""Views relating to `System` resource(s).""" +from flask import jsonify, Blueprint + +from gn_auth.auth.db.sqlite3 import with_db_connection + +from gn_auth.auth.authentication.oauth2.resource_server import require_oauth + +from gn_auth.auth.dictify import dictify + +from .models import user_roles_on_system + +system = Blueprint("system", __name__) + +@system.route("/roles") +def system_roles(): + """Get the roles that a user has that act on the system.""" + with require_oauth.acquire("profile group") as the_token: + roles = with_db_connection( + lambda conn: user_roles_on_system(conn, the_token.user)) + return jsonify(tuple(dictify(role) for role in roles)) |