diff --git a/docs/auth/silly/access.go b/docs/auth/silly/access.go index 134b0ae5..39318d1a 100644 --- a/docs/auth/silly/access.go +++ b/docs/auth/silly/access.go @@ -66,7 +66,7 @@ func (ac *accessController) Authorized(ctx context.Context, accessRecords ...aut return nil, &challenge } - return context.WithValue(ctx, "auth.user", auth.UserInfo{Name: "silly"}), nil + return auth.WithUser(ctx, auth.UserInfo{Name: "silly"}), nil } type challenge struct { diff --git a/docs/handlers/app.go b/docs/handlers/app.go index c106df47..8188c9cf 100644 --- a/docs/handlers/app.go +++ b/docs/handlers/app.go @@ -324,6 +324,9 @@ func (app *App) dispatcher(dispatch dispatchFunc) http.Handler { return } + // Add username to request logging + context.Context = ctxu.WithLogger(context.Context, ctxu.GetLogger(context.Context, "auth.user.name")) + if app.nameRequired(r) { repository, err := app.registry.Repository(context, getName(context)) @@ -456,7 +459,6 @@ func (app *App) authorized(w http.ResponseWriter, r *http.Request, context *Cont // should be replaced by another, rather than replacing the context on a // mutable object. context.Context = ctx - return nil }