mirror of
https://github.com/go-micro/go-micro.git
synced 2025-06-24 22:26:54 +02:00
Inject Namespace into Context
This commit is contained in:
@ -159,7 +159,7 @@ func AuthHandler(fn func() auth.Auth) server.HandlerWrapper {
|
||||
// Inspect the token and get the account
|
||||
account, err := a.Inspect(token)
|
||||
if err != nil {
|
||||
account = &auth.Account{}
|
||||
account = &auth.Account{Namespace: a.Options().Namespace}
|
||||
}
|
||||
|
||||
// construct the resource
|
||||
@ -183,6 +183,11 @@ func AuthHandler(fn func() auth.Auth) server.HandlerWrapper {
|
||||
return err
|
||||
}
|
||||
|
||||
// Set the namespace in the context
|
||||
if _, ok := metadata.Get(ctx, auth.NamespaceKey); !ok {
|
||||
ctx = metadata.Set(ctx, auth.NamespaceKey, a.Options().Namespace)
|
||||
}
|
||||
|
||||
// The user is authorised, allow the call
|
||||
return h(ctx, req, rsp)
|
||||
}
|
||||
|
Reference in New Issue
Block a user