Skip to content

Instantly share code, notes, and snippets.

@kkadir
Last active March 3, 2020 18:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kkadir/e79d7ea8e79f34dabd0f649261f5edd8 to your computer and use it in GitHub Desktop.
Save kkadir/e79d7ea8e79f34dabd0f649261f5edd8 to your computer and use it in GitHub Desktop.
The requirements for our custom policy providers
using System;
using Microsoft.AspNetCore.Authorization;
namespace CustomPolicyProvidersDemo.Authorization
{
public interface IIdentifiable
{
Guid Identifier { get; }
}
public class PermissionsRequirement : IAuthorizationRequirement, IIdentifiable
{
public PermissionsRequirement(string permissions, Guid identifier)
{
Permissions = permissions;
Identifier = identifier;
}
public string Permissions { get; }
public Guid Identifier { get; set; }
}
public class RolesRequirement : IAuthorizationRequirement, IIdentifiable
{
public RolesRequirement(string roles, Guid identifier)
{
Roles = roles;
Identifier = identifier;
}
public string Roles { get; }
public Guid Identifier { get; set; }
}
public class ScopesRequirement : IAuthorizationRequirement, IIdentifiable
{
public ScopesRequirement(string scopes, Guid identifier)
{
Scopes = scopes;
Identifier = identifier;
}
public string Scopes { get; }
public Guid Identifier { get; set; }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment