mirror of
https://github.com/hanzoai/tasks.git
synced 2026-11-03 03:56:04 +00:00
## What changed? Integrate Go 1.26's new `go fix` into workflow. NOTE that the changes caused our linter to fire; a [separate commit](https://github.com/temporalio/temporal/pull/9337/commits/1b23f787aef370098b35829c4d17dcc06230b4c1) addresses those. ## Why? Ensure Go code is standardized/modernized. ## How did you test it? - [ ] built - [ ] run locally and tested manually - [x] covered by existing tests - [ ] added new unit test(s) - [ ] added new functional test(s)
37 lines
1.0 KiB
Go
37 lines
1.0 KiB
Go
package authorization
|
|
|
|
type Role int16
|
|
|
|
// @@@SNIPSTART temporal-common-authorization-role-enum
|
|
// User authz within the context of an entity, such as system, namespace or workflow.
|
|
// User may have any combination of these authz within each context, except for RoleUndefined, as a bitmask.
|
|
const (
|
|
RoleWorker = Role(1 << iota)
|
|
RoleReader
|
|
RoleWriter
|
|
RoleAdmin
|
|
RoleUndefined = Role(0)
|
|
)
|
|
|
|
// @@@SNIPEND
|
|
|
|
// Checks if the provided role bitmask represents a valid combination of authz
|
|
func (b Role) IsValid() bool {
|
|
return b&^(RoleWorker|RoleReader|RoleWriter|RoleAdmin) == 0
|
|
}
|
|
|
|
// @@@SNIPSTART temporal-common-authorization-claims
|
|
// Claims contains the identity of the subject and subject's roles at the system level and for individual namespaces
|
|
type Claims struct {
|
|
// Identity of the subject
|
|
Subject string
|
|
// Role within the context of the whole Temporal cluster or a multi-cluster setup
|
|
System Role
|
|
// Roles within specific namespaces
|
|
Namespaces map[string]Role
|
|
// Free form bucket for extra data
|
|
Extensions any
|
|
}
|
|
|
|
// @@@SNIPEND
|