MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / getUserInfo

Method getUserInfo

rest/admin_api.go:1962–2004  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1960}
1961
1962func (h *handler) getUserInfo() error {
1963 h.assertAdminOnly()
1964 username := internalUserName(mux.Vars(h.rq)["name"])
1965 user, err := h.db.Authenticator(h.ctx()).GetUser(username)
1966 if user == nil {
1967 if err == nil {
1968 err = kNotFoundError
1969 }
1970 return err
1971 }
1972 // If not specified will default to false
1973 includeDynamicGrantInfo := h.permissionsResults[PermReadPrincipalAppData.PermissionName]
1974 info, err := marshalPrincipal(h.db, user, includeDynamicGrantInfo)
1975 if err != nil {
1976 return err
1977 }
1978 // If the user's OIDC issuer is no longer valid, remove the OIDC information to avoid confusing users
1979 // (it'll get removed permanently the next time the user signs in)
1980 if info.JWTIssuer != nil {
1981 issuerValid := false
1982 for _, provider := range h.db.OIDCProviders {
1983 if provider.Issuer == *info.JWTIssuer {
1984 issuerValid = true
1985 break
1986 }
1987 }
1988 if !issuerValid {
1989 info.JWTIssuer = nil
1990 info.JWTLastUpdated = nil
1991 info.JWTRoles = nil
1992 info.JWTChannels = nil
1993 }
1994 }
1995 bytes, err := base.JSONMarshal(info)
1996 if err == nil {
1997 base.Audit(h.ctx(), base.AuditIDUserRead, base.AuditFields{
1998 "db": h.db.Name,
1999 "username": username,
2000 })
2001 }
2002 h.writeRawJSON(bytes)
2003 return err
2004}
2005
2006func (h *handler) getRoleInfo() error {
2007 h.assertAdminOnly()

Callers

nothing calls this directly

Calls 9

assertAdminOnlyMethod · 0.95
ctxMethod · 0.95
writeRawJSONMethod · 0.95
JSONMarshalFunction · 0.92
AuditFunction · 0.92
internalUserNameFunction · 0.85
marshalPrincipalFunction · 0.85
GetUserMethod · 0.80
AuthenticatorMethod · 0.45

Tested by

no test coverage detected