Closed Mohido closed 2 years ago
@the4t4 if possible, can you change the /student/ in your other PR to the users/ router? and if possible as well, can you add the users/create endpoint. There is a TODO that concerns creating the users in the clean DB. So, it will be great if you can handle that. (Copy the /student/add that you have) into that endpoint. (#55)
User Documentation:
[GET] /users/get/self
: Get the current logged in user's details. It also contain the role (It is same as the /users/get/profile). However, /get/profile is no longer available.[GET] /users/get/all
: Get all users in the system. Valid users must exist in both, keycloak and cleanDB. Only admins, and demonstrators are authorized to get the users.[POST] /users/create
: Givenusers
in the request body which containsusername, firstname, lastname, roles, uid
, it creates the given users in the databases. It returns a dictionary (Map) ofusername => password
to the client. Onlyadmins
are valid to call this function.[PUT] /users/update/role
:Given ausername
and a list ofroles
in the request body, it assigns the given roles to the specific username. Onlyadmins
are able to call this function.Developer Documentation: Added multiple utilities in the keycloak_utils.
protector
: Authorization middleware. Given a list of roles, it checks if the logged in user has one of these roles.updateUserRole
: Given a username and a list of roles, it assigns these roles to the user with the given username.getAllRolesData
: As the name implies, it returns all the roles data in the realm. Roles data are the 'idin keycloak and
name` of the role.createUsers
: Given a list of KCUserData, it creates these users in keycloak. It assign random passwords to them. It returns a map ofusername => password
.getAllUsersData
: Get all the users in keycloak. It also can be filtered by roles if roles are given in the parameter.getSelfData
: Get thy data as KCUserDatagetUserData
: Get any given user data by its username.createClientAccessToken
: Creates an access token for the client. The client has the ability to alter the keycloak settings in our realm.