AuthenticationService  v0.2.0
Public Member Functions | List of all members
Joutsen.AuthenticationService.v2.RoleController Class Reference

A controller that manages user roles for applications managed by the service. More...

Public Member Functions

 RoleController (RoleRepository repository, UserRepository userRepository, ApplicationRepository applicationRepository)
 Creates a new instance of the controller. More...
 
IHttpActionResult Add ([Required] Role requestBody)
 Adds a role to a user for a specific application. More...
 
IHttpActionResult Delete ([Required] RoleIdentifier requestBody)
 Removes a role for a specific application from a user. More...
 
IHttpActionResult List ([Required] String username, String applicationName=null, String applicationKey=null, int pageNumber=0, int numberOfResults=int.MaxValue)
 Fetches all roles of a user for a specific application. More...
 

Detailed Description

A controller that manages user roles for applications managed by the service.

Remarks
Access to this controller is restricted to the administrator of the service and the administrators of the individual application.
Since
0.2.0

Constructor & Destructor Documentation

◆ RoleController()

Joutsen.AuthenticationService.v2.RoleController.RoleController ( RoleRepository  repository,
UserRepository  userRepository,
ApplicationRepository  applicationRepository 
)

Creates a new instance of the controller.

Member Function Documentation

◆ Add()

IHttpActionResult Joutsen.AuthenticationService.v2.RoleController.Add ( [Required] Role  requestBody)

Adds a role to a user for a specific application.

Parameters
requestBodythe model for the request body containing the name, user and application of the new role
descriptionan optional description of the role. If the description is omitted and a role with the same name already exists for the application the description is copied to the new role
Returns
HTTP 404 Not Found if the application or the user cannot be identified, HTTP 401 Unauthorized if the user trying to add the role is not an administrator for the service or the application, HTTP 200 OK if the role was successfully added.

◆ Delete()

IHttpActionResult Joutsen.AuthenticationService.v2.RoleController.Delete ( [Required] RoleIdentifier  requestBody)

Removes a role for a specific application from a user.

Parameters
requestBodythe model for the request body containing the identifiers of the role
Returns
HTTP 404 Not Found if the application or the user cannot be identified, HTTP 401 Unauthorized if the user trying to add the role is not an administrator for the service or the application, HTTP 200 OK if the role was successfully removed.

◆ List()

IHttpActionResult Joutsen.AuthenticationService.v2.RoleController.List ( [Required] String  username,
String  applicationName = null,
String  applicationKey = null,
int  pageNumber = 0,
int  numberOfResults = int.MaxValue 
)

Fetches all roles of a user for a specific application.

Parameters
usernamethe name of the user
applicationNamethe name of the application if it is identified by its name
applicationKeythe hash key of the application if it is identified by its key
pageNumberthe zero based page number to fetch
numberOfResultsthe maximum number of results to fetch
Returns
HTTP 404 Not Found if the application or the user cannot be identified, HTTP 401 Unauthorized if the user trying to add the role is not an administrator for the service or the application or the list of roles.
Remarks
This method is accessible for the service administrator as well as the administrator of the application that is requested. But it also allows a user to list his/her own roles for an application.