Authentication & Authorization

Serenity uses some abstractions to work with your application’s own user authentication and authorization mechanism.

  1. Serenity.Abstractions.IAuthenticationService
  2. Serenity.Abstractions.IAuthorizationService
  3. Serenity.Abstractions.IPermissionService
  4. Serenity.Abstractions.IUserRetrieveService

As Serenity doesn’t have default implementation for these abstractions, you should provide some implementation for them, using dependency registration system.

For example, Serenity Basic Application sample registers them in its SiteInitialization.ApplicationStart method like below:

  1. var registrar = Dependency.Resolve<IDependencyRegistrar>();
  2. registrar.RegisterInstance<IAuthorizationService>(
  3. new Administration.AuthorizationService());
  4. registrar.RegisterInstance<IAuthenticationService>(
  5. new Administration.AuthenticationService());
  6. registrar.RegisterInstance<IPermissionService>(
  7. new Administration.PermissionService());
  8. registrar.RegisterInstance<IUserRetrieveService>(
  9. new Administration.UserRetrieveService());

You might want to have a look at those sample implementations before writing your own.