AuthenticationService  v0.2.0
Static Public Member Functions | List of all members
Joutsen.AuthenticationService.ControllerAuthorization Class Reference

Controller extension methods that handle different authorization cases. More...

Static Public Member Functions

static void CheckIfAdmin (this ApiController controller)
 Checks if the current user is service administrator. More...
 
static void CheckIfAuthorized (this ApiController controller, Authentication.Application app, UserRepository repository, params string[] rolesToAuthorize)
 Checks if the current user is a service administrator or is granted access rights through different other roles. More...
 
static void CheckIfAuthorized (this ApiController controller, Authentication.User user, Authentication.Application app, UserRepository repository, params string[] rolesToAuthorize)
 Checks if the current user is a service administrator, is accesing its own records or is granted access rights through different other roles. More...
 
static void CheckIfAuthorized (this ApiController controller, String username)
 Checks if the current user is a service administrator or is accesing its own records roles. More...
 

Detailed Description

Controller extension methods that handle different authorization cases.

Since
0.2.0

Member Function Documentation

◆ CheckIfAdmin()

static void Joutsen.AuthenticationService.ControllerAuthorization.CheckIfAdmin ( this ApiController  controller)
static

Checks if the current user is service administrator.

Exceptions
AuthorizationExceptionif the current user is not a service administrator.

◆ CheckIfAuthorized() [1/3]

static void Joutsen.AuthenticationService.ControllerAuthorization.CheckIfAuthorized ( this ApiController  controller,
Authentication.Application  app,
UserRepository  repository,
params string []  rolesToAuthorize 
)
static

Checks if the current user is a service administrator or is granted access rights through different other roles.

Parameters
controllerthe controller
appthe application that identifies the users roles
repositrythe repository provides additional user data
rolesToAuthorizethe list of roles that authorize the user
Exceptions
AuthorizationExceptionif the user is not authorized through one of the roles or the service admin status

◆ CheckIfAuthorized() [2/3]

static void Joutsen.AuthenticationService.ControllerAuthorization.CheckIfAuthorized ( this ApiController  controller,
Authentication.User  user,
Authentication.Application  app,
UserRepository  repository,
params string []  rolesToAuthorize 
)
static

Checks if the current user is a service administrator, is accesing its own records or is granted access rights through different other roles.

Parameters
controllerthe controller
userthe user data to be changed
appthe application that identifies the users roles
repositrythe repository provides additional user data
rolesToAuthorizethe list of roles that authorize the user
Exceptions
AuthorizationExceptionif the user is not authorized through one of the roles its username or the service admin status

◆ CheckIfAuthorized() [3/3]

static void Joutsen.AuthenticationService.ControllerAuthorization.CheckIfAuthorized ( this ApiController  controller,
String  username 
)
static

Checks if the current user is a service administrator or is accesing its own records roles.

Parameters
controllerthe controller
usernamethe name of the user whose records are accessed
Exceptions
AuthorizationExceptionif the user is not authorized through username or the service admin status