Add authorized actions output on resources (#870)
This commit is contained in:
1 parent
ec6151d174
commit
dcb15cffbd
93 files changed
+2475
-1038
No files matched your search
+20
-5
@@ -554,9 +554,19 @@ func (r *VerifyResults) AdditionalVerification(ctx context.Context, opt ...Optio
|
||||
return
|
||||
}
|
||||
|
||||
// FetchActionsForId returns the allowed actions for a given ID using the
|
||||
// current set of ACLs and all other parameters the same (user, scope, etc.)
|
||||
func (r *VerifyResults) FetchActionsForId(ctx context.Context, id string, availableActions action.Actions, opt ...Option) action.Actions {
|
||||
// FetchActionSetForId returns the allowed actions for a given ID using the
|
||||
// current set of ACLs and all other parameters the same (user, etc.)
|
||||
func (r *VerifyResults) FetchActionSetForId(ctx context.Context, id string, availableActions action.ActionSet, opt ...Option) action.ActionSet {
|
||||
return r.fetchActions(ctx, id, resource.Unknown, availableActions, opt...)
|
||||
}
|
||||
|
||||
// FetchActionSetForType returns the allowed actions for a given collection type
|
||||
// using the current set of ACLs and all other parameters the same (user, etc.)
|
||||
func (r *VerifyResults) FetchActionSetForType(ctx context.Context, typ resource.Type, availableActions action.ActionSet, opt ...Option) action.ActionSet {
|
||||
return r.fetchActions(ctx, "", typ, availableActions, opt...)
|
||||
}
|
||||
|
||||
func (r *VerifyResults) fetchActions(ctx context.Context, id string, typ resource.Type, availableActions action.ActionSet, opt ...Option) action.ActionSet {
|
||||
switch {
|
||||
case r.v.requestInfo.DisableAuthEntirely,
|
||||
r.v.requestInfo.TokenFormat == AuthTokenTypeRecoveryKms:
|
||||
@@ -573,9 +583,14 @@ func (r *VerifyResults) FetchActionsForId(ctx context.Context, id string, availa
|
||||
if res == nil {
|
||||
res = new(perms.Resource)
|
||||
}
|
||||
res.Id = id
|
||||
if id != "" {
|
||||
res.Id = id
|
||||
}
|
||||
if typ != resource.Unknown {
|
||||
res.Type = typ
|
||||
}
|
||||
|
||||
ret := make(action.Actions, 0, len(availableActions))
|
||||
ret := make(action.ActionSet, 0, len(availableActions))
|
||||
for _, act := range availableActions {
|
||||
if r.v.acl.Allowed(*res, act).Allowed {
|
||||
ret = append(ret, act)
|
||||
|
||||
Reference in new issue
Block a user