-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ATLAS-10930: log which RBAC check (rbac/entitlement) failed authz #12
base: main
Are you sure you want to change the base?
Conversation
rchowinfoblox
commented
Aug 23, 2021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think obligation logs need to be more targeted and opt-in. We will get complaints that middleware is logging errors that people can not turn off.
@@ -252,6 +258,8 @@ func (a *DefaultAuthorizer) Evaluate(ctx context.Context, fullMethod string, grp | |||
} | |||
|
|||
if !opaResp.Allow() { | |||
forbidReason := opaResp.rbacForbiddenReason() | |||
logger.Infof("Request forbidden because these RBAC checks failed:%s", forbidReason) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will make it easier to find in kibana
logger.Infof("Request forbidden because these RBAC checks failed:%s", forbidReason) | |
logger.WithField("msg", forbidReason).Info("obligation_forbidden msg") |
@@ -252,6 +258,8 @@ func (a *DefaultAuthorizer) Evaluate(ctx context.Context, fullMethod string, grp | |||
} | |||
|
|||
if !opaResp.Allow() { | |||
forbidReason := opaResp.rbacForbiddenReason() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we first check that an obligation was expected? This is going to be triggered and have no message for 100% of authz failures today.
@@ -353,6 +361,32 @@ func (o OPAResponse) Allow() bool { | |||
return allow | |||
} | |||
|
|||
// If reason is available, returns reason RBAC was forbidden | |||
func (o OPAResponse) rbacForbiddenReason() string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the signature needs work here. We should distinguish lack of obligations from a specific obligation denial. You could also do that by emitting an error instead of a string. err == nil
nothing about obligations to report.
Also, how do services turn these logs off if they don't want them? Perhaps, don't log at all and return wrapped errors is a better way to enable implementation to choose behavior.
@@ -252,6 +258,8 @@ func (a *DefaultAuthorizer) Evaluate(ctx context.Context, fullMethod string, grp | |||
} | |||
|
|||
if !opaResp.Allow() { | |||
forbidReason := opaResp.rbacForbiddenReason() | |||
logger.Infof("Request forbidden because these RBAC checks failed:%s", forbidReason) | |||
return false, ctx, ErrForbidden |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another way to surface error messages is to wrap them in the error being returned.
return false, ctx, ErrForbidden | |
return false, ctx, fmt.Errorf("%w: %s", ErrForbidden, forbidReason) |
Caller verifies type of error with errors.Is(err, grpc_opa.ErrForbidden)
Labeled DO-NOT-MERGE as plan is now to use new print() rego function in more recent OPA versions to improve logging of request/response details in OPA log. |