Skip to content

Commit

Permalink
Move auth, metrics, meters to transitland-mw repo (#194)
Browse files Browse the repository at this point in the history
* Move auth, metrics, meters to transitland-mw repo
  • Loading branch information
irees authored Dec 11, 2023
1 parent 0c85bd8 commit 567b3d2
Show file tree
Hide file tree
Showing 83 changed files with 244 additions and 13,688 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: '^1.20.7'
go-version: '1.20.12'
- run: sudo apt-get install -y gdal-bin
- run: go install -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@latest
- run: git clone https://github.com/interline-io/transitland-lib.git
- run: dropdb --if-exists ${PGDATABASE}
- run: ${PWD}/transitland-lib/internal/schema/postgres/bootstrap.sh
- run: (cd cmd/tlserver && go install .)
- run: (cd cmd/tlserver && go version && go install .)
- run: ./test_setup.sh
- run: go test -v -count=1 ./...

11 changes: 6 additions & 5 deletions actions/fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,21 @@ import (
"time"

sq "github.com/Masterminds/squirrel"
"github.com/interline-io/log"
"github.com/interline-io/transitland-lib/dmfr/fetch"
"github.com/interline-io/transitland-lib/log"
"github.com/interline-io/transitland-lib/rt/pb"
"github.com/interline-io/transitland-lib/tl/tt"
"github.com/interline-io/transitland-lib/tldb"
"github.com/interline-io/transitland-server/auth/authn"
"github.com/interline-io/transitland-server/auth/authz"
"github.com/interline-io/transitland-mw/auth/authn"
"github.com/interline-io/transitland-mw/auth/authz"
"github.com/interline-io/transitland-server/config"
"github.com/interline-io/transitland-server/internal/dbutil"
"github.com/interline-io/transitland-server/model"
"github.com/jmoiron/sqlx"
"google.golang.org/protobuf/proto"
)

func StaticFetch(ctx context.Context, cfg config.Config, dbf model.Finder, feedId string, feedSrc io.Reader, feedUrl string, user authn.User, checker model.Checker) (*model.FeedVersionFetchResult, error) {
func StaticFetch(ctx context.Context, cfg config.Config, dbf model.Finder, feedId string, feedSrc io.Reader, feedUrl string, checker model.Checker) (*model.FeedVersionFetchResult, error) {
urlType := "static_current"
feed, err := fetchCheckFeed(ctx, dbf, checker, feedId, urlType, feedUrl)
if err != nil {
Expand All @@ -45,7 +45,8 @@ func StaticFetch(ctx context.Context, cfg config.Config, dbf model.Finder, feedI
FetchedAt: time.Now().In(time.UTC),
AllowFTPFetch: true,
}
if user != nil {

if user := authn.ForContext(ctx); user != nil {
fetchOpts.CreatedBy = tt.NewString(user.ID())
}

Expand Down
2 changes: 1 addition & 1 deletion actions/fetch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func TestStaticFetchWorker(t *testing.T) {
feedUrl := ts.URL + "/" + tc.serveFile
testfinder.FindersTxRollback(t, nil, nil, func(te model.Finders) {
// Run job
if result, err := StaticFetch(context.Background(), te.Config, te.Finder, tc.feedId, nil, feedUrl, nil, nil); err != nil && !tc.expectError {
if result, err := StaticFetch(context.Background(), te.Config, te.Finder, tc.feedId, nil, feedUrl, nil); err != nil && !tc.expectError {
_ = result
t.Fatal("unexpected error", err)
} else if err == nil && tc.expectError {
Expand Down
11 changes: 5 additions & 6 deletions actions/fv.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@ import (
"github.com/interline-io/transitland-lib/tl"
"github.com/interline-io/transitland-lib/tl/tt"
"github.com/interline-io/transitland-lib/tldb"
"github.com/interline-io/transitland-server/auth/authn"
"github.com/interline-io/transitland-server/auth/authz"
"github.com/interline-io/transitland-mw/auth/authz"
"github.com/interline-io/transitland-server/config"
"github.com/interline-io/transitland-server/model"
)

func FeedVersionImport(ctx context.Context, cfg config.Config, dbf model.Finder, checker model.Checker, user authn.User, fvid int) (*model.FeedVersionImportResult, error) {
func FeedVersionImport(ctx context.Context, cfg config.Config, dbf model.Finder, checker model.Checker, fvid int) (*model.FeedVersionImportResult, error) {
if checker == nil {
return nil, authz.ErrUnauthorized
}
Expand All @@ -39,7 +38,7 @@ func FeedVersionImport(ctx context.Context, cfg config.Config, dbf model.Finder,
return &mr, nil
}

func FeedVersionUnimport(ctx context.Context, cfg config.Config, dbf model.Finder, checker model.Checker, user authn.User, fvid int) (*model.FeedVersionUnimportResult, error) {
func FeedVersionUnimport(ctx context.Context, cfg config.Config, dbf model.Finder, checker model.Checker, fvid int) (*model.FeedVersionUnimportResult, error) {
if checker == nil {
return nil, authz.ErrUnauthorized
}
Expand All @@ -60,7 +59,7 @@ func FeedVersionUnimport(ctx context.Context, cfg config.Config, dbf model.Finde
return &mr, nil
}

func FeedVersionUpdate(ctx context.Context, cfg config.Config, dbf model.Finder, checker model.Checker, user authn.User, fvid int, values model.FeedVersionSetInput) error {
func FeedVersionUpdate(ctx context.Context, cfg config.Config, dbf model.Finder, checker model.Checker, fvid int, values model.FeedVersionSetInput) error {
if checker == nil {
return authz.ErrUnauthorized
}
Expand Down Expand Up @@ -94,7 +93,7 @@ func FeedVersionUpdate(ctx context.Context, cfg config.Config, dbf model.Finder,
return nil
}

func FeedVersionDelete(ctx context.Context, cfg config.Config, dbf model.Finder, checker model.Checker, user authn.User, fvid int) (*model.FeedVersionDeleteResult, error) {
func FeedVersionDelete(ctx context.Context, cfg config.Config, dbf model.Finder, checker model.Checker, fvid int) (*model.FeedVersionDeleteResult, error) {
if checker == nil {
return nil, authz.ErrUnauthorized
}
Expand Down
3 changes: 1 addition & 2 deletions actions/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"github.com/interline-io/transitland-lib/tl/tt"
"github.com/interline-io/transitland-lib/tlcsv"
"github.com/interline-io/transitland-lib/validator"
"github.com/interline-io/transitland-server/auth/authn"
"github.com/interline-io/transitland-server/config"
"github.com/interline-io/transitland-server/model"
)
Expand All @@ -22,7 +21,7 @@ type hasGeometries interface {
}

// ValidateUpload takes a file Reader and produces a validation package containing errors, warnings, file infos, service levels, etc.
func ValidateUpload(ctx context.Context, cfg config.Config, src io.Reader, feedURL *string, rturls []string, user authn.User) (*model.ValidationResult, error) {
func ValidateUpload(ctx context.Context, cfg config.Config, src io.Reader, feedURL *string, rturls []string) (*model.ValidationResult, error) {
// Check inputs
rturlsok := []string{}
for _, rturl := range rturls {
Expand Down
169 changes: 0 additions & 169 deletions auth/ancheck/gatekeeper.go

This file was deleted.

Loading

0 comments on commit 567b3d2

Please sign in to comment.