Pass more session info around, make proxy UX nicer (#385)
This commit is contained in:
1 parent
e937b0ea27
commit
4669c95999
13 files changed
+368
-225
No files matched your search
@@ -96,7 +96,7 @@ func (s Service) getFromRepo(ctx context.Context, id string) (*pb.Session, error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
sess, err := repo.LookupSession(ctx, id)
|
||||
sess, _, err := repo.LookupSession(ctx, id)
|
||||
if err != nil {
|
||||
if errors.Is(err, db.ErrRecordNotFound) {
|
||||
return nil, handlers.NotFoundErrorf("Session %q doesn't exist.", id)
|
||||
@@ -165,7 +165,7 @@ func (s Service) authResult(ctx context.Context, id string, a action.Type) auth.
|
||||
res.Error = err
|
||||
return res
|
||||
}
|
||||
t, err := repo.LookupSession(ctx, id)
|
||||
t, _, err := repo.LookupSession(ctx, id)
|
||||
if err != nil {
|
||||
res.Error = err
|
||||
return res
|
||||
|
||||
@@ -388,14 +388,15 @@ HostSetIterationLoop:
|
||||
}
|
||||
|
||||
sad := &pb.SessionAuthorizationData{
|
||||
SessionId: sess.PublicId,
|
||||
TargetId: t.GetPublicId(),
|
||||
Scope: authResults.Scope,
|
||||
CreatedTime: sess.CreateTime.GetTimestamp(),
|
||||
Type: t.GetType(),
|
||||
Certificate: sess.Certificate,
|
||||
PrivateKey: privKey,
|
||||
WorkerInfo: workers,
|
||||
SessionId: sess.PublicId,
|
||||
TargetId: t.GetPublicId(),
|
||||
Scope: authResults.Scope,
|
||||
CreatedTime: sess.CreateTime.GetTimestamp(),
|
||||
Type: t.GetType(),
|
||||
Certificate: sess.Certificate,
|
||||
PrivateKey: privKey,
|
||||
WorkerInfo: workers,
|
||||
ConnectionLimit: t.GetSessionConnectionLimit(),
|
||||
}
|
||||
marshaledSad, err := proto.Marshal(sad)
|
||||
if err != nil {
|
||||
|
||||
@@ -85,7 +85,7 @@ func (ws *workerServiceServer) Status(ctx context.Context, req *pbs.StatusReques
|
||||
continue
|
||||
}
|
||||
sessionId := si.GetSessionId()
|
||||
sessionInfo, err := sessRepo.LookupSession(ctx, sessionId)
|
||||
sessionInfo, _, err := sessRepo.LookupSession(ctx, sessionId)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "Error looking up session with id %s: %v", sessionId, err)
|
||||
}
|
||||
@@ -129,7 +129,7 @@ func (ws *workerServiceServer) LookupSession(ctx context.Context, req *pbs.Looku
|
||||
return nil, status.Errorf(codes.Internal, "Error getting session repo: %v", err)
|
||||
}
|
||||
|
||||
sessionInfo, err := sessRepo.LookupSession(ctx, req.GetSessionId())
|
||||
sessionInfo, authzSummary, err := sessRepo.LookupSession(ctx, req.GetSessionId())
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "Error looking up session: %v", err)
|
||||
}
|
||||
@@ -145,11 +145,16 @@ func (ws *workerServiceServer) LookupSession(ctx context.Context, req *pbs.Looku
|
||||
SessionId: sessionInfo.GetPublicId(),
|
||||
Certificate: sessionInfo.Certificate,
|
||||
},
|
||||
Status: sessionInfo.States[0].Status.ProtoVal(),
|
||||
Version: sessionInfo.Version,
|
||||
TofuToken: string(sessionInfo.TofuToken),
|
||||
Endpoint: sessionInfo.Endpoint,
|
||||
Expiration: sessionInfo.ExpirationTime.Timestamp,
|
||||
Status: sessionInfo.States[0].Status.ProtoVal(),
|
||||
Version: sessionInfo.Version,
|
||||
TofuToken: string(sessionInfo.TofuToken),
|
||||
Endpoint: sessionInfo.Endpoint,
|
||||
Expiration: sessionInfo.ExpirationTime.Timestamp,
|
||||
ConnectionLimit: sessionInfo.ConnectionLimit,
|
||||
ConnectionsLeft: authzSummary.ConnectionLimit,
|
||||
}
|
||||
if resp.ConnectionsLeft != -1 {
|
||||
resp.ConnectionsLeft -= int32(authzSummary.CurrentConnectionCount)
|
||||
}
|
||||
|
||||
wrapper, err := ws.kms.GetWrapper(ctx, sessionInfo.ScopeId, kms.KeyPurposeSessions)
|
||||
|
||||
Reference in new issue
Block a user