Skip to content

Commit

Permalink
remove auth middleware (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
wasaga authored Jul 21, 2022
1 parent 5a61087 commit eb6a0ae
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 404 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ lint: ## run go mod tidy

.PHONY: tidy
tidy: ## run go mod tidy
go mod tidy -compat=1.17
go mod tidy -compat=1.18

.PHONY: clean
clean: ## Cleanup any build binaries or packages.
Expand Down
3 changes: 0 additions & 3 deletions cmd/pomerium-datasource/bamboohr.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ type bambooCmd struct {
BambooSubdomain string `validate:"required,hostname,excludesrune=."`
BambooTimeZone string `validate:"required"`
Address string `validate:"required"`
BearerToken string `validate:"required"`
Debug bool
cobra.Command `validate:"-"`
zerolog.Logger `validate:"-"`
Expand All @@ -44,7 +43,6 @@ func (cmd *bambooCmd) setupFlags() {
flags.StringVar(&cmd.BambooSubdomain, "bamboohr-subdomain", "", "BambooHR subdomain, i.e. if your instance is corp.bamboohr.com, then subdomain is corp")
flags.StringVar(&cmd.BambooAPIKey, "bamboohr-api-key", "", "api key, see https://documentation.bamboohr.com/docs#section-authentication")
flags.StringVar(&cmd.BambooTimeZone, "bamboohr-time-zone", "UTC", "BambooHR global time zone, see Settings > Account > General Settings > Time Zone ")
flags.StringVar(&cmd.BearerToken, "bearer-token", "", "all requests must contain Authorization: Bearer header matching this token")
flags.BoolVar(&cmd.Debug, "debug", false, "turns debug mode on that would dump requests and responses")
flags.StringVar(&cmd.Address, "address", ":8080", "tcp address to listen to")
}
Expand Down Expand Up @@ -85,6 +83,5 @@ func (cmd *bambooCmd) newServer() (http.Handler, error) {
client = server.NewDebugClient(http.DefaultClient, cmd.Logger)
}
srv := bamboohr.NewServer(emplReq, client, cmd.Logger)
srv.Use(server.AuthorizationBearerMiddleware(cmd.BearerToken))
return srv, nil
}
5 changes: 1 addition & 4 deletions cmd/pomerium-datasource/zenefits.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ import (
type zenefitsCmd struct {
APIKey string `validate:"required"`

BearerToken string `validate:"required"`
Address string `validate:"required"`
Address string `validate:"required"`

TimeZone string

Expand All @@ -45,7 +44,6 @@ func zenefitsCommand(log zerolog.Logger) *cobra.Command {
func (cmd *zenefitsCmd) setupFlags() {
flags := cmd.Flags()
flags.StringVar(&cmd.APIKey, "zenefits-api-key", "", "Bearer API token https://developers.zenefits.com/v1.0/docs/auth")
flags.StringVar(&cmd.BearerToken, "bearer-token", "", "all requests must contain Authorization: Bearer header matching this token")
flags.StringVar(&cmd.Address, "address", "localhost:8080", "tcp address to listen on")
flags.StringVar(&cmd.TimeZone, "time-zone", "UTC", "timezone, required for vacation data")
flags.BoolVar(&cmd.Debug, "debug", false, "turns debug mode on that would dump requests and responses")
Expand Down Expand Up @@ -81,6 +79,5 @@ func (cmd *zenefitsCmd) newServer() (http.Handler, error) {
srv := zenefits.NewServer(zenefits.PeopleRequest{}, client,
zenefits.WithLogger(cmd.Logger),
zenefits.WithRemoveOnVacation(location))
srv.Use(server.AuthorizationBearerMiddleware(cmd.BearerToken))
return srv, nil
}
8 changes: 5 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module github.com/pomerium/datasource
go 1.18

require (
github.com/bradenaw/juniper v0.7.0
github.com/client9/misspell v0.3.4
github.com/gabriel-vasile/mimetype v1.4.1
github.com/go-playground/validator/v10 v10.11.0
Expand All @@ -27,6 +26,7 @@ require (
github.com/Masterminds/semver v1.5.0 // indirect
github.com/OpenPeeDeeP/depguard v1.1.0 // indirect
github.com/alexkohler/prealloc v1.0.0 // indirect
github.com/alingse/asasalint v0.0.10 // indirect
github.com/ashanbrown/forbidigo v1.3.0 // indirect
github.com/ashanbrown/makezero v1.1.1 // indirect
github.com/beorn7/perks v1.0.1 // indirect
Expand Down Expand Up @@ -137,6 +137,7 @@ require (
github.com/shazow/go-diff v0.0.0-20160112020656-b6b7b6733b8c // indirect
github.com/sirupsen/logrus v1.8.1 // indirect
github.com/sivchari/containedctx v1.0.2 // indirect
github.com/sivchari/nosnakecase v1.5.0 // indirect
github.com/sivchari/tenv v1.7.0 // indirect
github.com/sonatard/noctx v0.0.1 // indirect
github.com/sourcegraph/go-diff v0.6.1 // indirect
Expand All @@ -161,15 +162,16 @@ require (
github.com/yagipy/maintidx v1.0.0 // indirect
github.com/yeya24/promlinter v0.2.0 // indirect
gitlab.com/bosi/decorder v0.2.2 // indirect
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
go.uber.org/zap v1.17.0 // indirect
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e // indirect
golang.org/x/exp v0.0.0-20220217172124-1812c5b45e43 // indirect
golang.org/x/exp/typeparams v0.0.0-20220613132600-b0d781184e0d // indirect
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect
golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e // indirect
golang.org/x/sys v0.0.0-20220702020025-31831981b65f // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/tools v0.1.12-0.20220628192153-7743d1d949f1 // indirect
golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df // indirect
google.golang.org/protobuf v1.28.0 // indirect
gopkg.in/ini.v1 v1.66.6 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
Expand Down
Loading

0 comments on commit eb6a0ae

Please sign in to comment.