mirror of
https://github.com/paralus/paralus.git
synced 2026-05-11 02:46:57 +00:00
multiple kratos clients for session validation and identity creation (#114)
* multiple kratos clients for session validation and identity creation * fixed review comments * switching few logs to debug
This commit is contained in:
@@ -106,12 +106,14 @@ func (ac authContext) NewAuthUnaryInterceptor(opt Option) grpc.UnaryServerInterc
|
||||
}
|
||||
|
||||
s := res.GetStatus()
|
||||
_log.Debug("user authentication status ", s)
|
||||
switch s {
|
||||
case commonv3.RequestStatus_RequestAllowed:
|
||||
sd := res.SessionData
|
||||
sd.ClientIp = ip
|
||||
sd.ClientHost = host
|
||||
sd.ClientUa = ua
|
||||
_log.Debug("session data ", sd)
|
||||
ctx := context.WithValue(ctx, common.SessionDataKey, sd)
|
||||
return handler(ctx, req)
|
||||
case commonv3.RequestStatus_RequestMethodOrURLNotAllowed:
|
||||
|
||||
@@ -84,7 +84,7 @@ func (ac *authContext) authenticate(ctx context.Context, httpreq *http.Request,
|
||||
res.Reason = "no or invalid credentials"
|
||||
return false, nil
|
||||
} else {
|
||||
return false, nil
|
||||
return false, err
|
||||
}
|
||||
}
|
||||
if session.GetActive() {
|
||||
|
||||
@@ -466,7 +466,7 @@ func (s *userService) GetUserInfo(ctx context.Context, user *userv3.User) (*user
|
||||
if s.dev {
|
||||
username = user.GetMetadata().GetName()
|
||||
if len(username) == 0 {
|
||||
fmt.Println("Unable to fetch username. Don't use DEV mode when using from UI.")
|
||||
_log.Warn("Unable to fetch username. Don't use DEV mode when using from UI.")
|
||||
return &userv3.UserInfo{}, fmt.Errorf("username should be provided")
|
||||
}
|
||||
} else {
|
||||
@@ -476,6 +476,7 @@ func (s *userService) GetUserInfo(ctx context.Context, user *userv3.User) (*user
|
||||
}
|
||||
username = sd.Username
|
||||
}
|
||||
_log.Info("username ", username)
|
||||
|
||||
entity, err := dao.GetByTraits(ctx, s.db, username, &models.KratosIdentities{})
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user