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:
Marwan Sulaiman
2020-07-30 17:06:53 -04:00
committed by GitHub
parent 81906b918f
commit dfb7887080
19 changed files with 546 additions and 135 deletions
+5 -1
View File
@@ -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)