Skip to content

Commit

Permalink
Remove confusing error message for unauthenticated API calls (libopen…
Browse files Browse the repository at this point in the history
…storage#1489)

Signed-off-by: Grant Griffiths <[email protected]>
  • Loading branch information
ggriffiths authored Apr 3, 2020
1 parent 0840cd6 commit 9a43a98
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions api/server/sdk/server_interceptors.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,12 @@ func (s *sdkGrpcServer) authorizationServerInterceptor(
// Authorize
if err := s.roleServer.Verify(ctx, claims.Roles, info.FullMethod); err != nil {
logger.Warning("Access denied")
if auth.IsPublic(ctx) {
return nil, status.Errorf(
codes.PermissionDenied,
"Access denied without authentication token")
}

return nil, status.Errorf(
codes.PermissionDenied,
"Access to %s denied: %v",
Expand Down
2 changes: 1 addition & 1 deletion api/server/sdk/server_interceptors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func TestAuthorizationServerInterceptorCreate(t *testing.T) {
RequestAuthenticated: false,

ExpectSuccess: false,
ExpectedError: "rpc error: code = PermissionDenied desc = Access to /openstorage.api.OpenStorageVolume/Create denied: rpc error: code = PermissionDenied desc = Access denied to roles: [system.public]",
ExpectedError: "rpc error: code = PermissionDenied desc = Access denied without authentication token",
},
{
TestName: "2-1: Authenticated volume creation should succeed with public vol creation enabled",
Expand Down

0 comments on commit 9a43a98

Please sign in to comment.