-
-
Notifications
You must be signed in to change notification settings - Fork 685
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(rbac): refact rbac support more groups(roles)
- Loading branch information
Showing
53 changed files
with
433 additions
and
327 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
|
||
export interface IActionDef { | ||
[key: string]: string | ||
} | ||
|
||
export const FunctionActionDef = { | ||
ListFunctions: 'fn:ListFunctions', | ||
GetFunction: 'fn:GetFunction', | ||
CreateFunction: 'fn:CreateFunction', | ||
UpdateFunction: 'fn:UpdateFunction', | ||
DeleteFunction: 'fn:DeleteFunction', | ||
InvokeFunction: 'fn:InvokeFunction', | ||
PublishFunction: 'fn:PublishFunction', | ||
ListLogs: 'fn:ListLogs', | ||
} | ||
|
||
export const ApplicationActionDef = { | ||
ListApplications: 'app:ListApplications', | ||
GetApplication: 'app:GetApplication', | ||
CreateApplication: 'app:CreateApplication', | ||
UpdateApplication: 'app:UpdateApplication', | ||
DeleteApplication: 'app:DeleteApplication', | ||
StartInstance: 'app:StartInstance', | ||
StopInstance: 'app:StopInstance', | ||
} | ||
|
||
export const DatabaseActionDef = { | ||
ListCollections: 'db:ListCollections', | ||
GetCollection: 'db:GetCollection', | ||
CreateCollection: 'db:CreateCollection', | ||
UpdateCollection: 'db:UpdateCollection', | ||
DeleteCollection: 'db:DeleteCollection', | ||
ListDocuments: 'db:ListDocuments', | ||
GetDocument: 'db:GetDocument', | ||
CreateDocument: 'db:CreateDocument', | ||
UpdateDocument: 'db:UpdateDocument', | ||
DeleteDocument: 'db:DeleteDocument', | ||
ListPolicies: 'db:ListPolicies', | ||
GetPolicy: 'db:GetPolicy', | ||
CreatePolicy: 'db:CreatePolicy', | ||
UpdatePolicy: 'db:UpdatePolicy', | ||
DeletePolicy: 'db:DeletePolicy', | ||
PublishPolicy: 'db:PublishPolicy', | ||
} | ||
|
||
export const StorageActionDef = { | ||
ListBuckets: 'oss:ListBuckets', | ||
GetBucket: 'oss:GetBucket', | ||
CreateBucket: 'oss:CreateBucket', | ||
UpdateBucket: 'oss:UpdateBucket', | ||
DeleteBucket: 'oss:DeleteBucket', | ||
CreateServiceAccount: 'oss:CreateServiceAccount', | ||
} | ||
|
||
export const ReplicationActionDef = { | ||
ListReplicateAuth: 'rep:ListReplicateAuth', | ||
GetReplicateAuth: 'rep:GetReplicateAuth', | ||
CreateReplicateAuth: 'rep:CreateReplicateAuth', | ||
UpdateReplicateAuth: 'rep:UpdateReplicateAuth', | ||
DeleteReplicateAuth: 'rep:DeleteReplicateAuth', | ||
ListReplicateRequest: 'rep:ListReplicateRequest', | ||
GetReplicateRequest: 'rep:GetReplicateRequest', | ||
CreateReplicateRequest: 'rep:CreateReplicateRequest', | ||
UpdateReplicateRequest: 'rep:UpdateReplicateRequest', | ||
DeleteReplicateRequest: 'rep:DeleteReplicateRequest', | ||
} | ||
|
||
export const WebsiteActionDef = { | ||
ListWebsites: 'web:ListWebsites', | ||
GetWebsite: 'web:GetWebsite', | ||
CreateWebsite: 'web:CreateWebsite', | ||
UpdateWebsite: 'web:UpdateWebsite', | ||
DeleteWebsite: 'web:DeleteWebsite', | ||
} | ||
|
||
|
||
export function get_actions(action_def: IActionDef) { | ||
const actions: string[] = [] | ||
for (const key in action_def) { | ||
if (action_def.hasOwnProperty(key)) { | ||
actions.push(action_def[key]) | ||
} | ||
} | ||
return actions | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
|
||
import { get_actions, FunctionActionDef, DatabaseActionDef, StorageActionDef, ReplicationActionDef, ApplicationActionDef, WebsiteActionDef } from './actions' | ||
|
||
|
||
export const FunctionReadyOnly = { | ||
name: 'FunctionReadyOnly', | ||
label: 'Function Ready Only', | ||
actions: [ | ||
FunctionActionDef.ListFunctions, | ||
FunctionActionDef.GetFunction, | ||
FunctionActionDef.ListLogs | ||
] | ||
} | ||
|
||
export const FunctionFullAccess = { | ||
name: 'FunctionFullAccess', | ||
label: 'Function Full Access', | ||
actions: get_actions(FunctionActionDef) | ||
} | ||
|
||
export const DatabaseReadyOnly = { | ||
name: 'DatabaseReadyOnly', | ||
label: 'Database Ready Only', | ||
actions: [ | ||
DatabaseActionDef.ListCollections, | ||
DatabaseActionDef.GetCollection, | ||
DatabaseActionDef.ListDocuments, | ||
DatabaseActionDef.GetDocument, | ||
DatabaseActionDef.ListPolicies, | ||
DatabaseActionDef.GetPolicy, | ||
] | ||
} | ||
|
||
export const DatabaseFullAccess = { | ||
name: 'DatabaseFullAccess', | ||
label: 'Database Full Access', | ||
actions: get_actions(DatabaseActionDef) | ||
} | ||
|
||
export const StorageReadOnly = { | ||
name: 'StorageReadOnly', | ||
label: 'Storage Read Only', | ||
actions: [ | ||
StorageActionDef.ListBuckets, | ||
StorageActionDef.GetBucket, | ||
] | ||
} | ||
|
||
export const StorageFullAccess = { | ||
name: 'StorageFullAccess', | ||
label: 'Storage Full Access', | ||
actions: get_actions(StorageActionDef) | ||
} | ||
|
||
export const ReplicationReadOnly = { | ||
name: 'ReplicationReadOnly', | ||
label: 'Replication Read Only', | ||
actions: [ | ||
ReplicationActionDef.ListReplicateAuth, | ||
ReplicationActionDef.GetReplicateAuth, | ||
ReplicationActionDef.ListReplicateRequest, | ||
ReplicationActionDef.GetReplicateRequest, | ||
] | ||
} | ||
|
||
export const ReplicationFullAccess = { | ||
name: 'ReplicationFullAccess', | ||
label: 'Replication Full Access', | ||
actions: get_actions(ReplicationActionDef) | ||
} | ||
|
||
export const ApplicationReadOnly = { | ||
name: 'ApplicationReadOnly', | ||
label: 'Application Read Only', | ||
actions: [ | ||
ApplicationActionDef.ListApplications, | ||
ApplicationActionDef.GetApplication, | ||
] | ||
} | ||
|
||
export const InstanceOperator = { | ||
name: 'InstanceOperator', | ||
label: 'Instance Operator', | ||
actions: [ | ||
ApplicationActionDef.StartInstance, | ||
ApplicationActionDef.StopInstance, | ||
] | ||
} | ||
|
||
export const ApplicationFullAccess = { | ||
name: 'ApplicationFullAccess', | ||
label: 'Application Full Access', | ||
actions: get_actions(ApplicationActionDef) | ||
} | ||
|
||
export const WebsiteReadOnly = { | ||
name: 'WebsiteReadOnly', | ||
label: 'Website Read Only', | ||
actions: [ | ||
WebsiteActionDef.ListWebsites, | ||
WebsiteActionDef.GetWebsite, | ||
] | ||
} | ||
|
||
export const WebsiteFullAccess = { | ||
name: 'WebsiteFullAccess', | ||
label: 'Website Full Access', | ||
actions: get_actions(WebsiteActionDef) | ||
} | ||
|
||
export const Admin = { | ||
name: 'Admin', | ||
label: 'Admin', | ||
actions: [ | ||
...get_actions(FunctionActionDef), | ||
...get_actions(DatabaseActionDef), | ||
...get_actions(StorageActionDef), | ||
...get_actions(ReplicationActionDef), | ||
...get_actions(ApplicationActionDef), | ||
...get_actions(WebsiteActionDef), | ||
] | ||
} | ||
|
||
export const Groups = [ | ||
FunctionReadyOnly, | ||
FunctionFullAccess, | ||
DatabaseReadyOnly, | ||
DatabaseFullAccess, | ||
StorageReadOnly, | ||
StorageFullAccess, | ||
ReplicationReadOnly, | ||
ReplicationFullAccess, | ||
ApplicationReadOnly, | ||
InstanceOperator, | ||
ApplicationFullAccess, | ||
WebsiteReadOnly, | ||
WebsiteFullAccess, | ||
Admin | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.