# Manage Strategy
The core of Authing's access control and permission management model is designed around two points: Resource and Policy. A policy defines a certain operation authority(s) for a certain resource (class). By authorizing the policy to a user (or role), you can know whether the user (or role) has operation authority for a certain operation of a resource .
# Add strategy
PoliciesManagementClient().create(code, policy statement, detailed format and description, please see, description)
Add strategy
# Parameters
code
<string> strategy unique markPolicy statement, detailed format and description, please refer to
<PolicyStatement[]> https://docs.authing.co/docs/access-control/index.htmldescription
<string> description
# Example
var list = await managementClient.Policies.Create(code, new PolicyStatementInput[] {
new PolicyStatementInput("book:123", new string[] {"book:edit" })
});
# Delete strategy
PoliciesManagementClient().delete(code)
Delete strategy, the system built-in strategy is officially maintained by Authing and cannot be modified or deleted.
# Parameters
code
<string> strategy unique mark
# Example
var message = await managementClient.Policies.Delete("PolicyCode");
# Batch delete strategy
PoliciesManagementClient().deleteMany(codeList)
Batch delete policies. The built-in policies of the system are officially maintained by Authing and cannot be modified or deleted.
# Parameters
codeList
<string> strategy unique flag list
# Example
var message = await managementClient.Policies.DeleteMany(new string[] {code });
# Modify strategy
PoliciesManagementClient().update(code, updates)
Modify the strategy. The built-in strategy of the system is officially maintained by Authing and cannot be modified or deleted.
# Parameters
code
<string> strategy unique markupdates
<Object>updates.description
<string> descriptionupdates.statements
<PolicyStatement[]> policy statement, please refer to https://docs.authing.co/docs/access-control/index.html for detailed format and descriptionupdates.newCode
<string> The new unique flag. If it is passed in, it must be guaranteed to be unique in the user pool.
# Example
var policy = await managementClient.Policies.Update(code, description: "asd");
# Get policy details
PoliciesManagementClient().detail(code)
Get policy details
# Parameters
code
<string> strategy unique mark
const policy = await managementClient.policies.detail('CODE');
# Example
var policy = await managementClient.Policies.Detail(code);
# Get a list of strategies
PoliciesManagementClient().list(options)
Get a list of strategies
# Parameters
options
<Object>options.page
<number> The default value is:1
.options.limit
<number> The default value is:10
.options.excludeDefault
<boolean> Whether to exclude system default resources or not. The default value istrue
.
# Example
var list = await managementClient.Policies.List();
# Get policy authorization record
PoliciesManagementClient().listAssignments(code, page, limit)
Obtain policy authorization records
# Parameters
code
<string> strategy unique markpage
<number> The default value is:1
.limit
<number> The default value is10
.
# Example
var list = await managementClient.Policies.ListAssignments(code);
# Add policy authorization
PoliciesManagementClient().addAssignments(policies, targetType, targetIdentifiers)
Add policy authorization, the policy can be authorized to users and roles, and the policy authorized to the role will be inherited by all users under the role. This interface can perform batch operations.
# Parameters
policies
<string[]> policy code listtargetType
<PolicyAssignmentTargetType> Optional values are USER (user) and ROLE (role)targetIdentifiers
<string[]> user id list and role code list
# Example
var list = await managementClient.Policies.AddAssignments(new string[] {code }, PolicyAssignmentTargetType.USER, new string[] {userId });
# Revoke policy authorization
PoliciesManagementClient().removeAssignments(policies, targetType, targetIdentifiers)
Revocation of policy authorization, this interface can be used for batch operations.
# Parameters
policies
<string[]> policy code listtargetType
<PolicyAssignmentTargetType> Optional values are USER (user) and ROLE (role)targetIdentifiers
<string[]> user id list and role code list
# Example
var list = await managementClient.Policies.RemoveAssignments(new string[] {code }, PolicyAssignmentTargetType.USER, new string[] {userId });