MCPcopy Index your code
hub / github.com/coder/coder / HasOrganizationMembership

Method HasOrganizationMembership

coderd/rbac/authz.go:180–194  ·  view source on GitHub ↗

HasOrganizationMembership reports whether the subject has explicit membership in organizationID through an org-scoped role. Site-wide roles alone do not count as organization membership.

(organizationID uuid.UUID)

Source from the content-addressed store, hash-verified

178// membership in organizationID through an org-scoped role. Site-wide roles
179// alone do not count as organization membership.
180func (s Subject) HasOrganizationMembership(organizationID uuid.UUID) (bool, error) {
181 roles, err := s.Roles.Expand()
182 if err != nil {
183 return false, xerrors.Errorf("expand user authorization roles: %w", err)
184 }
185
186 organizationIDString := organizationID.String()
187 for _, role := range roles {
188 if _, ok := role.ByOrgID[organizationIDString]; ok {
189 return true, nil
190 }
191 }
192
193 return false, nil
194}
195
196type Authorizer interface {
197 // Authorize will authorize the given subject to perform the given action

Callers 2

postChatsMethod · 0.80
authorizeRequestMethod · 0.80

Calls 3

ExpandMethod · 0.65
ErrorfMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected