C# Library

Register authorization provider:

  1: Sidvall.AuthorizationManager.SystemContext.Current.InitializeSqlServer("ConnectionString");
  2: var authorizationProvider = new Sidvall.AuthorizationManager.Security.AuthorizationProvider();
  3: authorizationProvider.LoadFromJson("JSON string created by the management tool");
  4: Sidvall.Services.ServiceManager.Current.RegisterInstance<Sidvall.Security.IAuthorizationProvider>(authorizationProvider);
  5: Sidvall.Services.ServiceManager.Current.RegisterInstance<Sidvall.Security.IUserProvider>(authorizationProvider);


Authorize user with code:

  1: principal = Sidvall.SystemContext.Current.PrincipalProvider.CurrentPrincipal;
  2: isAuthorized = Sidvall.SystemContext.Current.AuthorizationManager.IsAuthorized(principal, "My Resource", "Action");
  3: isAuthorized = await Sidvall.SystemContext.Current.AuthorizationManager.IsAuthorizedAsync(principal, "My Resource", "Action", "SubAction");
  4: isAuthorized = await Sidvall.SystemContext.Current.AuthorizationManager.IsAuthorizedAsync(principal, "My Resource", "Action", "SubAction", "Resource Item Id");

Authorize user with attribute:

  1: [Sidvall.IdentityModel.WebApi.ResourceActionAuthorize("GetItem", "My Resource"]
  2: public async Task<HttpResponseMessage> GetItemByPrimaryKey(long id)


Get list of resources to which the user is authorized to use:

var items = await Sidvall.SystemContext.Current.AuthorizationManager.GetResourceItemsAsync()

Management Tool

The management tool is available as a ClickOnce package.

Database

Is available as a sql-script.

Database

Last edited Feb 18, 2015 at 7:43 AM by sidwall, version 13