2022-01-26 09:16:33 +00:00
|
|
|
package domain
|
|
|
|
|
2023-05-05 15:34:53 +00:00
|
|
|
import "context"
|
|
|
|
|
2022-01-26 09:16:33 +00:00
|
|
|
type Permissions struct {
|
|
|
|
Permissions []string
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *Permissions) AppendPermissions(ctxID string, permissions ...string) {
|
|
|
|
for _, permission := range permissions {
|
|
|
|
p.appendPermission(ctxID, permission)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *Permissions) appendPermission(ctxID, permission string) {
|
|
|
|
if ctxID != "" {
|
|
|
|
permission = permission + ":" + ctxID
|
|
|
|
}
|
|
|
|
for _, existingPermission := range p.Permissions {
|
|
|
|
if existingPermission == permission {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
p.Permissions = append(p.Permissions, permission)
|
|
|
|
}
|
2023-05-05 15:34:53 +00:00
|
|
|
|
|
|
|
type PermissionCheck func(ctx context.Context, permission, orgID, resourceID string) (err error)
|
|
|
|
|
|
|
|
const (
|
2024-05-07 05:38:26 +00:00
|
|
|
PermissionUserWrite = "user.write"
|
|
|
|
PermissionUserRead = "user.read"
|
|
|
|
PermissionUserDelete = "user.delete"
|
|
|
|
PermissionUserCredentialWrite = "user.credential.write"
|
|
|
|
PermissionSessionWrite = "session.write"
|
|
|
|
PermissionSessionDelete = "session.delete"
|
2024-08-14 18:18:29 +00:00
|
|
|
PermissionIDPRead = "iam.idp.read"
|
|
|
|
PermissionOrgIDPRead = "org.idp.read"
|
2023-05-05 15:34:53 +00:00
|
|
|
)
|