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

Method initUserPrefix

auth/jwt.go:234–251  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

232}
233
234func (l *LocalJWTAuthProvider) initUserPrefix(ctx context.Context) {
235 if l.UserPrefix != "" || l.UsernameClaim != "" {
236 return
237 }
238
239 issuerURL, err := url.ParseRequestURI(l.Issuer)
240 if err != nil {
241 base.WarnfCtx(ctx, "Unable to parse issuer URI when initializing user prefix - using provider name")
242 l.UserPrefix = l.name
243 return
244 }
245 l.UserPrefix = issuerURL.Host + issuerURL.Path
246
247 // If the prefix contains forward slash or underscore, it's not valid as-is for a username: forward slash
248 // breaks the REST API, underscore breaks uniqueness of "[prefix]_[sub]". URL encode the prefix to cover
249 // this scenario
250 l.UserPrefix = url.QueryEscape(l.UserPrefix)
251}
252
253type LocalJWTConfig map[string]LocalJWTAuthConfig
254type LocalJWTProviderMap map[string]*LocalJWTAuthProvider

Callers 1

BuildProviderMethod · 0.95

Calls 1

WarnfCtxFunction · 0.92

Tested by

no test coverage detected