Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move events.go out of internal/authenticateflow #4852

Merged
merged 2 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions authenticate/config.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package authenticate

import (
"github.com/pomerium/pomerium/authenticate/events"
"github.com/pomerium/pomerium/config"
"github.com/pomerium/pomerium/internal/authenticateflow"
"github.com/pomerium/pomerium/internal/identity"
identitypb "github.com/pomerium/pomerium/pkg/grpc/identity"
)

type authenticateConfig struct {
getIdentityProvider func(options *config.Options, idpID string) (identity.Authenticator, error)
profileTrimFn func(*identitypb.Profile)
authEventFn authenticateflow.AuthEventFn
authEventFn events.AuthEventFn
}

// An Option customizes the Authenticate config.
Expand Down Expand Up @@ -40,7 +40,7 @@ func WithProfileTrimFn(profileTrimFn func(*identitypb.Profile)) Option {
}

// WithOnAuthenticationEventHook sets the authEventFn function in the config
func WithOnAuthenticationEventHook(fn authenticateflow.AuthEventFn) Option {
func WithOnAuthenticationEventHook(fn events.AuthEventFn) Option {
return func(cfg *authenticateConfig) {
cfg.authEventFn = fn
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
package authenticateflow
// Package events defines authentication flow event types.
package events

import (
"context"
Expand Down
11 changes: 6 additions & 5 deletions internal/authenticateflow/stateless.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"golang.org/x/oauth2"
"google.golang.org/protobuf/encoding/protojson"

"github.com/pomerium/pomerium/authenticate/events"
"github.com/pomerium/pomerium/config"
"github.com/pomerium/pomerium/internal/encoding"
"github.com/pomerium/pomerium/internal/encoding/jws"
Expand Down Expand Up @@ -57,7 +58,7 @@ type Stateless struct {

getIdentityProvider func(options *config.Options, idpID string) (identity.Authenticator, error)
profileTrimFn func(*identitypb.Profile)
authEventFn AuthEventFn
authEventFn events.AuthEventFn
}

// NewStateless initializes the authentication flow for the given
Expand All @@ -67,7 +68,7 @@ func NewStateless(
sessionStore sessions.SessionStore,
getIdentityProvider func(options *config.Options, idpID string) (identity.Authenticator, error),
profileTrimFn func(*identitypb.Profile),
authEventFn AuthEventFn,
authEventFn events.AuthEventFn,
) (*Stateless, error) {
s := &Stateless{
options: cfg.Options,
Expand Down Expand Up @@ -295,7 +296,7 @@ func (s *Stateless) logAuthenticateEvent(r *http.Request, profile *identitypb.Pr
log.Warn(ctx).Err(err).Msg("log authenticate event: failed to decrypt request params")
}

evt := AuthEvent{
evt := events.AuthEvent{
IP: httputil.GetClientIP(r),
Version: params.Get(urlutil.QueryVersion),
RequestUUID: params.Get(urlutil.QueryRequestUUID),
Expand All @@ -310,9 +311,9 @@ func (s *Stateless) logAuthenticateEvent(r *http.Request, profile *identitypb.Pr
}

if evt.UID != nil {
evt.Event = AuthEventSignInComplete
evt.Event = events.AuthEventSignInComplete
} else {
evt.Event = AuthEventSignInRequest
evt.Event = events.AuthEventSignInRequest
}

if redirectURL, err := url.Parse(params.Get(urlutil.QueryRedirectURI)); err == nil {
Expand Down