mirror of
https://github.com/gomods/athens
synced 2026-02-03 11:00:32 +00:00
Allow Athens to Propagate Authentication to Mod Download (#1650)
* Allow Athens to Propagate Authentication to Mod Download * update readme * add pattern matching to auth propagation * Propagate authentication to pre declared static host * quote redis test * fix flaky redis error message * fix config tests * fix config tests * Update config.dev.toml Co-authored-by: Ted Wexler <ted@stuckinacan.com> * gofmt Co-authored-by: Ted Wexler <ted@stuckinacan.com>
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/gomods/athens/pkg/auth"
|
||||
"github.com/gomods/athens/pkg/errors"
|
||||
"github.com/gomods/athens/pkg/index"
|
||||
"github.com/gomods/athens/pkg/log"
|
||||
@@ -52,9 +53,12 @@ func (s *stasher) Stash(ctx context.Context, mod, ver string) (string, error) {
|
||||
|
||||
// create a new context that ditches whatever deadline the caller passed
|
||||
// but keep the tracing info so that we can properly trace the whole thing.
|
||||
tok, ok := auth.FromContext(ctx)
|
||||
ctx, cancel := context.WithTimeout(trace.NewContext(context.Background(), span), time.Minute*10)
|
||||
defer cancel()
|
||||
|
||||
if ok {
|
||||
ctx = auth.SetAuthInContext(ctx, tok)
|
||||
}
|
||||
v, err := s.fetchModule(ctx, mod, ver)
|
||||
if err != nil {
|
||||
return "", errors.E(op, err)
|
||||
|
||||
Reference in New Issue
Block a user