MCPcopy Index your code
hub / github.com/rilldata/rill / jwtAttributesForUser

Method jwtAttributesForUser

admin/server/server.go:363–392  ·  view source on GitHub ↗
(ctx context.Context, userID, orgID string, projectPermissions *adminv1.ProjectPermissions)

Source from the content-addressed store, hash-verified

361}
362
363func (s *Server) jwtAttributesForUser(ctx context.Context, userID, orgID string, projectPermissions *adminv1.ProjectPermissions) (map[string]any, error) {
364 user, attributes, err := s.admin.DB.FindUserWithAttributes(ctx, userID, orgID)
365 if err != nil {
366 return nil, err
367 }
368
369 groups, err := s.admin.DB.FindUsergroupsForUser(ctx, user.ID, orgID)
370 if err != nil {
371 return nil, err
372 }
373
374 groupNames := make([]any, len(groups))
375 for i, group := range groups {
376 groupNames[i] = group.Name
377 }
378
379 attr := map[string]any{
380 "name": user.DisplayName,
381 "email": user.Email,
382 "domain": user.Email[strings.LastIndex(user.Email, "@")+1:],
383 "groups": groupNames,
384 "admin": projectPermissions.ManageProject,
385 }
386
387 for k, v := range attributes {
388 attr[k] = v
389 }
390
391 return attr, nil
392}
393
394func (s *Server) jwtAttributesForService(ctx context.Context, serviceID string, projectPermissions *adminv1.ProjectPermissions) (map[string]any, error) {
395 service, err := s.admin.DB.FindService(ctx, serviceID)

Callers 4

createMagicTokensMethod · 0.95
issueRuntimeTokenMethod · 0.95
IssueMagicAuthTokenMethod · 0.95
getAttributesForUserMethod · 0.95

Calls 2

FindUsergroupsForUserMethod · 0.65

Tested by

no test coverage detected