Session Refactor: Add auth module label to session's list (#94958)

* Add AuthModule to token API

* Add badge to UserSessions

* Change idp label rendering

* Render IdP label for User Profile page

* Add i18n labels
This commit is contained in:
linoman
2024-10-22 10:57:36 +02:00
committed by GitHub
parent 200c613672
commit 3270a9c959
10 changed files with 36 additions and 1 deletions
+8
View File
@@ -15,6 +15,7 @@ import (
"github.com/grafana/grafana/pkg/services/auth"
"github.com/grafana/grafana/pkg/services/authn"
contextmodel "github.com/grafana/grafana/pkg/services/contexthandler/model"
"github.com/grafana/grafana/pkg/services/login"
"github.com/grafana/grafana/pkg/services/user"
"github.com/grafana/grafana/pkg/util"
"github.com/grafana/grafana/pkg/web"
@@ -224,6 +225,12 @@ func (hs *HTTPServer) getUserAuthTokensInternal(c *contextmodel.ReqContext, user
seenAt = createdAt
}
// Retrieve AuthModule from external session
authModule := ""
if externalSession, err := hs.AuthTokenService.GetExternalSession(c.Req.Context(), token.ExternalSessionId); err == nil {
authModule = login.GetAuthProviderLabel(externalSession.AuthModule)
}
result = append(result, &dtos.UserToken{
Id: token.Id,
IsActive: isActive,
@@ -233,6 +240,7 @@ func (hs *HTTPServer) getUserAuthTokensInternal(c *contextmodel.ReqContext, user
OperatingSystemVersion: osVersion,
Browser: client.UserAgent.Family,
BrowserVersion: browserVersion,
AuthModule: authModule,
CreatedAt: createdAt,
SeenAt: seenAt,
})