From 92f2f3468829ba6521c6339b1e2a520ae613d4a3 Mon Sep 17 00:00:00 2001 From: Ingo Oppermann Date: Wed, 29 Nov 2023 10:32:47 +0100 Subject: [PATCH] Create only available fields in token --- http/handler/api/session.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/http/handler/api/session.go b/http/handler/api/session.go index 1af4689b..d5266970 100644 --- a/http/handler/api/session.go +++ b/http/handler/api/session.go @@ -119,10 +119,18 @@ func (s *SessionHandler) CreateToken(c echo.Context) error { } for i, req := range request { - data := map[string]interface{}{ - "match": req.Match, - "remote": req.Remote, - "extra": req.Extra, + data := map[string]interface{}{} + + if len(req.Match) != 0 { + data["match"] = req.Match + } + + if len(req.Remote) != 0 { + data["remote"] = req.Remote + } + + if len(req.Extra) != 0 { + data["extra"] = req.Extra } request[i].Token = identity.GetServiceSession(data, time.Duration(req.TTL)*time.Second)