cleanup some shit in auth service
This commit is contained in:
@@ -3,14 +3,12 @@ package grpc
|
||||
import (
|
||||
"context"
|
||||
"log"
|
||||
"strings"
|
||||
|
||||
"datarush/internal/auth/domain"
|
||||
"datarush/internal/auth/service"
|
||||
pb "datarush/pkg/api/auth"
|
||||
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/metadata"
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
@@ -58,18 +56,8 @@ func (h *AuthHandler) SignIn(ctx context.Context, req *pb.SignInRequest) (*pb.Si
|
||||
func (h *AuthHandler) ValidateToken(ctx context.Context, req *pb.ValidateTokenRequest) (*pb.ValidateTokenResponse, error) {
|
||||
token := req.Token
|
||||
|
||||
// If token is empty, try to get it from Authorization header (for gRPC-Gateway)
|
||||
if token == "" {
|
||||
md, ok := metadata.FromIncomingContext(ctx)
|
||||
if ok {
|
||||
authHeaders := md.Get("authorization")
|
||||
if len(authHeaders) > 0 {
|
||||
parts := strings.Split(authHeaders[0], " ")
|
||||
if len(parts) == 2 && parts[0] == "Bearer" {
|
||||
token = parts[1]
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil, status.Error(codes.Unauthenticated, "missing token")
|
||||
}
|
||||
|
||||
if token == "" {
|
||||
|
||||
Reference in New Issue
Block a user