MCPcopy Create free account
hub / github.com/StackStorm/st2 / get

Method get

st2api/st2api/controllers/v1/user.py:24–60  ·  view source on GitHub ↗

Meta API endpoint wich returns information about the currently authenticated user. Handle: GET /v1/user

(self, requester_user, auth_info)

Source from the content-addressed store, hash-verified

22
23class UserController(object):
24 def get(self, requester_user, auth_info):
25 """
26 Meta API endpoint wich returns information about the currently authenticated user.
27
28 Handle:
29 GET /v1/user
30 """
31
32 data = {}
33
34 rbac_utils = get_rbac_backend().get_utils_class()
35 rbac_service = get_rbac_backend().get_service_class()
36
37 if cfg.CONF.rbac.enable and requester_user:
38 role_dbs = rbac_service.get_roles_for_user(user_db=requester_user)
39 roles = [role_db.name for role_db in role_dbs]
40 else:
41 roles = []
42
43 data = {
44 "username": requester_user.name,
45 "authentication": {
46 "method": auth_info["method"],
47 "location": auth_info["location"],
48 },
49 "rbac": {
50 "enabled": cfg.CONF.rbac.enable,
51 "roles": roles,
52 "is_admin": rbac_utils.user_is_admin(user_db=requester_user),
53 },
54 }
55
56 if auth_info.get("token_expire", None):
57 token_expire = auth_info["token_expire"].strftime("%Y-%m-%dT%H:%M:%SZ")
58 data["authentication"]["token_expire"] = token_expire
59
60 return data
61
62
63user_controller = UserController()

Callers 15

apply_vagrant_workaroundFunction · 0.45
shutdownMethod · 0.45
_cancel_actionMethod · 0.45
_pause_actionMethod · 0.45
_resume_actionMethod · 0.45
_get_rerun_referenceMethod · 0.45
_get_runnerMethod · 0.45
_create_auth_tokenMethod · 0.45
processMethod · 0.45
shutdownMethod · 0.45

Calls 5

get_rbac_backendFunction · 0.90
get_utils_classMethod · 0.45
get_service_classMethod · 0.45
get_roles_for_userMethod · 0.45
user_is_adminMethod · 0.45

Tested by 15

test_dispatchMethod · 0.36
_get_action_executionMethod · 0.36
test_get_indexMethod · 0.36
test_get_allMethod · 0.36
test_get_oneMethod · 0.36
test_index_healthMethod · 0.36