mirror of
https://github.com/pomerium/pomerium.git
synced 2025-08-03 08:50:42 +02:00
Fix many instances of contexts and loggers not being propagated (#5340)
This also replaces instances where we manually write "return ctx.Err()" with "return context.Cause(ctx)" which is functionally identical, but will also correctly propagate cause errors if present.
This commit is contained in:
parent
e1880ba20f
commit
fe31799eb5
77 changed files with 297 additions and 221 deletions
|
@ -56,7 +56,7 @@ type Stateful struct {
|
|||
|
||||
// NewStateful initializes the authentication flow for the given configuration
|
||||
// and session store.
|
||||
func NewStateful(cfg *config.Config, sessionStore sessions.SessionStore) (*Stateful, error) {
|
||||
func NewStateful(ctx context.Context, cfg *config.Config, sessionStore sessions.SessionStore) (*Stateful, error) {
|
||||
s := &Stateful{
|
||||
sessionDuration: cfg.Options.CookieExpire,
|
||||
sessionStore: sessionStore,
|
||||
|
@ -88,7 +88,7 @@ func NewStateful(cfg *config.Config, sessionStore sessions.SessionStore) (*State
|
|||
s.defaultIdentityProviderID = idp.GetId()
|
||||
}
|
||||
|
||||
dataBrokerConn, err := outboundGRPCConnection.Get(context.Background(),
|
||||
dataBrokerConn, err := outboundGRPCConnection.Get(ctx,
|
||||
&grpc.OutboundOptions{
|
||||
OutboundPort: cfg.OutboundPort,
|
||||
InstallationID: cfg.Options.InstallationID,
|
||||
|
|
|
@ -69,7 +69,7 @@ func TestStatefulSignIn(t *testing.T) {
|
|||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
sessionStore := &mstore.Store{SaveError: tt.saveError}
|
||||
flow, err := NewStateful(&config.Config{Options: opts}, sessionStore)
|
||||
flow, err := NewStateful(context.Background(), &config.Config{Options: opts}, sessionStore)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -123,7 +123,7 @@ func TestStatefulAuthenticateSignInURL(t *testing.T) {
|
|||
opts.AuthenticateURLString = "https://authenticate.example.com"
|
||||
key := cryptutil.NewKey()
|
||||
opts.SharedKey = base64.StdEncoding.EncodeToString(key)
|
||||
flow, err := NewStateful(&config.Config{Options: opts}, nil)
|
||||
flow, err := NewStateful(context.Background(), &config.Config{Options: opts}, nil)
|
||||
require.NoError(t, err)
|
||||
|
||||
t.Run("NilQueryParams", func(t *testing.T) {
|
||||
|
@ -238,7 +238,7 @@ func TestStatefulCallback(t *testing.T) {
|
|||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
flow, err := NewStateful(&config.Config{Options: opts}, tt.sessionStore)
|
||||
flow, err := NewStateful(context.Background(), &config.Config{Options: opts}, tt.sessionStore)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -289,7 +289,7 @@ func TestStatefulCallback(t *testing.T) {
|
|||
|
||||
func TestStatefulRevokeSession(t *testing.T) {
|
||||
opts := config.NewDefaultOptions()
|
||||
flow, err := NewStateful(&config.Config{Options: opts}, nil)
|
||||
flow, err := NewStateful(context.Background(), &config.Config{Options: opts}, nil)
|
||||
require.NoError(t, err)
|
||||
|
||||
ctrl := gomock.NewController(t)
|
||||
|
@ -367,7 +367,7 @@ func TestPersistSession(t *testing.T) {
|
|||
|
||||
opts := config.NewDefaultOptions()
|
||||
opts.CookieExpire = 4 * time.Hour
|
||||
flow, err := NewStateful(&config.Config{Options: opts}, nil)
|
||||
flow, err := NewStateful(context.Background(), &config.Config{Options: opts}, nil)
|
||||
require.NoError(t, err)
|
||||
|
||||
ctrl := gomock.NewController(t)
|
||||
|
|
|
@ -64,6 +64,7 @@ type Stateless struct {
|
|||
// NewStateless initializes the authentication flow for the given
|
||||
// configuration, session store, and additional options.
|
||||
func NewStateless(
|
||||
ctx context.Context,
|
||||
cfg *config.Config,
|
||||
sessionStore sessions.SessionStore,
|
||||
getIdentityProvider func(options *config.Options, idpID string) (identity.Authenticator, error),
|
||||
|
@ -131,7 +132,7 @@ func NewStateless(
|
|||
return nil, fmt.Errorf("authorize: get authenticate JWKS key fetcher: %w", err)
|
||||
}
|
||||
|
||||
dataBrokerConn, err := outboundGRPCConnection.Get(context.Background(), &grpc.OutboundOptions{
|
||||
dataBrokerConn, err := outboundGRPCConnection.Get(ctx, &grpc.OutboundOptions{
|
||||
OutboundPort: cfg.OutboundPort,
|
||||
InstallationID: cfg.Options.InstallationID,
|
||||
ServiceName: cfg.Options.Services,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue