-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
875 additions
and
277 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package impl | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/jumpserver/wisp/pkg/jms-sdk-go/model" | ||
"github.com/jumpserver/wisp/pkg/logger" | ||
pb "github.com/jumpserver/wisp/protobuf-go/protobuf" | ||
) | ||
|
||
func (j *JMServer) RecordSessionLifecycleLog(ctx context.Context, req *pb.SessionLifecycleLogRequest) (*pb.StatusResponse, error) { | ||
var ( | ||
status pb.Status | ||
) | ||
sessionId := req.GetSessionId() | ||
event := req.GetEvent() | ||
reason := req.GetReason() | ||
user := req.GetUser() | ||
logObj := model.SessionLifecycleLog{Reason: reason, User: user} | ||
lifecycleEvent := LifecycleEventMap[event] | ||
logger.Infof("Request record session %s lifecyle %s : %s", sessionId, event, logObj) | ||
if err := j.apiClient.RecordSessionLifecycleLog(sessionId, lifecycleEvent, logObj); err != nil { | ||
logger.Errorf("Record session %s lifecyle failed: %s", sessionId, err) | ||
status.Err = err.Error() | ||
return &pb.StatusResponse{Status: &status}, nil | ||
} | ||
status.Ok = true | ||
return &pb.StatusResponse{Status: &status}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package service | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/jumpserver/wisp/pkg/jms-sdk-go/model" | ||
) | ||
|
||
func (s *JMService) RecordSessionLifecycleLog(sid string, event model.LifecycleEvent, logObj model.SessionLifecycleLog) (err error) { | ||
data := map[string]interface{}{ | ||
"event": event, | ||
} | ||
if logObj.Reason != "" { | ||
data["reason"] = logObj.Reason | ||
} | ||
if logObj.User != "" { | ||
data["user"] = logObj.User | ||
} | ||
|
||
reqURL := fmt.Sprintf(SessionLifecycleLogURL, sid) | ||
var resp map[string]interface{} | ||
_, err = s.authClient.Post(reqURL, data, &resp) | ||
return | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.