snapshot of https://github.com/cortezaproject/corteza.git (2024.9.x, 2026-09-18; blobs > 131072B omitted)
Some checks failed
SonarQube / SonarQube (push) Failing after 5m28s
E2e test on main branch push / server and client test (map[name:admin port:8080]) (push) Failing after 3m33s
Server and lib tests / Library test (js) (push) Failing after 1m36s
Server and lib tests / Library test (vue) (push) Successful in 2m24s
Server and lib tests / Web client test (admin) (push) Successful in 2m52s
Server and lib tests / Web client test (compose) (push) Successful in 3m23s
Server and lib tests / Web client test (discovery) (push) Successful in 2m49s
Server and lib tests / Web client test (one) (push) Successful in 2m52s
Server and lib tests / Web client test (privacy) (push) Successful in 2m44s
Server and lib tests / Web client test (reporter) (push) Successful in 2m56s
Server and lib tests / Web client test (workflow) (push) Successful in 3m0s
Server and lib tests / Server tests (push) Failing after 4m55s
E2e test on main branch push / notify-failure (push) Failing after 9s
Server and lib tests / Send matrix testing notification (push) Successful in 2s
Mark stale issues and pull requests / stale (push) Successful in 40s
Some checks failed
SonarQube / SonarQube (push) Failing after 5m28s
E2e test on main branch push / server and client test (map[name:admin port:8080]) (push) Failing after 3m33s
Server and lib tests / Library test (js) (push) Failing after 1m36s
Server and lib tests / Library test (vue) (push) Successful in 2m24s
Server and lib tests / Web client test (admin) (push) Successful in 2m52s
Server and lib tests / Web client test (compose) (push) Successful in 3m23s
Server and lib tests / Web client test (discovery) (push) Successful in 2m49s
Server and lib tests / Web client test (one) (push) Successful in 2m52s
Server and lib tests / Web client test (privacy) (push) Successful in 2m44s
Server and lib tests / Web client test (reporter) (push) Successful in 2m56s
Server and lib tests / Web client test (workflow) (push) Successful in 3m0s
Server and lib tests / Server tests (push) Failing after 4m55s
E2e test on main branch push / notify-failure (push) Failing after 9s
Server and lib tests / Send matrix testing notification (push) Successful in 2s
Mark stale issues and pull requests / stale (push) Successful in 40s
This commit is contained in:
90
server/pkg/auth/system.go
Normal file
90
server/pkg/auth/system.go
Normal file
@@ -0,0 +1,90 @@
|
||||
package auth
|
||||
|
||||
import (
|
||||
"github.com/cortezaproject/corteza/server/system/types"
|
||||
)
|
||||
|
||||
const (
|
||||
ProvisionUserHandle = "corteza-provisioner"
|
||||
ServiceUserHandle = "corteza-service"
|
||||
FederationUserHandle = "corteza-federation"
|
||||
|
||||
BypassRoleHandle = "super-admin"
|
||||
AuthenticatedRoleHandle = "authenticated"
|
||||
AnonymousRoleHandle = "anonymous"
|
||||
)
|
||||
|
||||
var (
|
||||
provisionUser *types.User
|
||||
serviceUser *types.User
|
||||
federationUser *types.User
|
||||
|
||||
authenticatedRoles []*types.Role
|
||||
anonymousRoles []*types.Role
|
||||
bypassRoles []*types.Role
|
||||
)
|
||||
|
||||
// SetSystemUsers takes list of users and sets/updates appropriate
|
||||
// provision, service & fed users
|
||||
//
|
||||
// These are then accessed via special *User() fn.
|
||||
func SetSystemUsers(uu types.UserSet, rr types.RoleSet) {
|
||||
bpr := rr.FindByHandle(BypassRoleHandle)
|
||||
|
||||
for _, u := range uu {
|
||||
switch u.Handle {
|
||||
case ProvisionUserHandle:
|
||||
provisionUser = u.Clone()
|
||||
provisionUser.SetRoles(bpr.ID)
|
||||
case ServiceUserHandle:
|
||||
serviceUser = u.Clone()
|
||||
serviceUser.SetRoles(bpr.ID)
|
||||
case FederationUserHandle:
|
||||
federationUser = u.Clone()
|
||||
federationUser.SetRoles(bpr.ID)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func SetSystemRoles(rr types.RoleSet) {
|
||||
for _, r := range rr {
|
||||
switch r.Handle {
|
||||
case BypassRoleHandle:
|
||||
bypassRoles = append(bypassRoles, r.Clone())
|
||||
case AuthenticatedRoleHandle:
|
||||
authenticatedRoles = append(authenticatedRoles, r.Clone())
|
||||
case AnonymousRoleHandle:
|
||||
anonymousRoles = append(anonymousRoles, r.Clone())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// BypassRoles returns all bypass Roles
|
||||
func BypassRoles() types.RoleSet {
|
||||
return bypassRoles
|
||||
}
|
||||
|
||||
// AuthenticatedRoles returns all authenticated Roles
|
||||
func AuthenticatedRoles() types.RoleSet {
|
||||
return authenticatedRoles
|
||||
}
|
||||
|
||||
// AnonymousRoles returns all anonymous Roles
|
||||
func AnonymousRoles() types.RoleSet {
|
||||
return anonymousRoles
|
||||
}
|
||||
|
||||
// ProvisionUser returns clone of system provision user
|
||||
func ProvisionUser() *types.User {
|
||||
return provisionUser.Clone()
|
||||
}
|
||||
|
||||
// ServiceUser returns clone of system service user
|
||||
func ServiceUser() *types.User {
|
||||
return serviceUser.Clone()
|
||||
}
|
||||
|
||||
// FederationUser returns clone of system federation user
|
||||
func FederationUser() *types.User {
|
||||
return federationUser.Clone()
|
||||
}
|
||||
Reference in New Issue
Block a user