fix: Updated authentication check endpoint to take the auth token as POST request data

This commit is contained in:
Andrey Melnikov
2020-03-24 15:55:51 -07:00
parent a02e8f7d61
commit 570e5d9322
6 changed files with 160 additions and 68 deletions

View File

@@ -81,6 +81,27 @@ func IsAuthorized(c *v1.Client, namespace, verb, group, resource, name string) (
func AuthUnaryInterceptor(kubeConfig *v1.Config, db *v1.DB) grpc.UnaryServerInterceptor {
return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, err error) {
if info.FullMethod == "/api.AuthService/IsValidToken" {
md, ok := metadata.FromIncomingContext(ctx)
if !ok {
return resp, errors.New("unable to get metadata from incoming context")
}
tokenRequest, ok := req.(*api.IsValidTokenRequest)
if !ok {
return resp, errors.New("IsValidToken does not have correct request type")
}
md.Set("authorization", tokenRequest.Token.Token)
ctx, err = getClient(ctx, kubeConfig, db)
if err != nil {
ctx = nil
}
return handler(ctx, req)
}
ctx, err = getClient(ctx, kubeConfig, db)
if err != nil {
return