mirror of
https://github.com/onepanelio/onepanel.git
synced 2025-09-27 10:02:10 +08:00
fix: Updated authentication check endpoint to take the auth token as POST request data
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user