Skip to content

Commit

Permalink
Merge pull request #74 from dzungtran/dependabot/go_modules/golang.or…
Browse files Browse the repository at this point in the history
…g/x/crypto-0.17.0
  • Loading branch information
dependabot[bot] authored Dec 19, 2023
2 parents 1efc9dc + 94ea737 commit 2844eb2
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 243 deletions.
3 changes: 0 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,5 @@ AUTH_PROVIDER=firebase
FIREBASE_CREDENTIALS='{firebase json admin key}'
FIREBASE_AUTH_CREDENTIALS='{filebase json auth key}'

# KRATOS_API_ENDPOINT=http://kratos:4433/
# KRATOS_WEBHOOK_API_KEY=very-very-very-secure-api-key

AUTO_MIGRATE=true
PORT=8088
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ Any feedback and pull requests are welcome and highly appreciated. Feel free to
<!--toc-->
- [Echo REST API boilerplate](#echo-rest-api-boilerplate)
- [HOW TO USE THIS TEMPLATE](#how-to-use-this-template)
- [Overview](#overview)
- [Features](#features)
- [Running the project](#running-the-project)
- [Swagger Docs](#swagger-docs)
- [Environment variables](#environment-variables)
- [Commands](#commands)
- [Folder structure](#folder-structure)
- [Open source refs](#open-source-refs)
- [Folder Structure](#folder-structure)
- [Open Source Refs](#open-source-refs)
- [Contributing](#contributing)
- [TODOs](#todos)

Expand All @@ -39,8 +41,6 @@ Any feedback and pull requests are welcome and highly appreciated. Feel free to
<!--
## Overview
![Request processing flow - Sequence Diagram](out/docs/diagrams/overview/request_flow.svg) -->
## Features
Expand Down Expand Up @@ -86,8 +86,6 @@ Setting your config as Environment Variables is recommended as by 12-Factor App.
| AUTH_PROVIDER | string | Optional | firebase_auth |
| FIREBASE_CREDENTIALS | json | firebase json admin key | {firebase_admin_key} |
| FIREBASE_AUTH_CREDENTIALS | json | filebase json auth key | {firebase_auth_key} |
| KRATOS_API_ENDPOINT | string | [DEPRECATED] Public endpoint of Kratos | http://kratos:4433/ |
| KRATOS_WEBHOOK_API_KEY | string | [DEPRECATED] Api key for Kratos integration | very-very-very-secure-api-key |
</details>
## Commands
Expand Down
9 changes: 4 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,10 @@ require (
github.com/lib/pq v1.10.6
github.com/lithammer/shortuuid/v4 v4.0.0
github.com/open-policy-agent/opa v0.54.0
github.com/ory/kratos-client-go v0.11.1
github.com/spf13/cobra v1.7.0
github.com/stretchr/testify v1.8.2
github.com/swaggo/echo-swagger v1.4.0
github.com/swaggo/swag v1.16.1
github.com/tidwall/gjson v1.17.0
github.com/tidwall/sjson v1.2.5
go.uber.org/dig v1.17.0
go.uber.org/zap v1.24.0
Expand Down Expand Up @@ -104,6 +102,7 @@ require (
github.com/spf13/pflag v1.0.5 // indirect
github.com/swaggo/files/v2 v2.0.0 // indirect
github.com/tchap/go-patricia/v2 v2.3.1 // indirect
github.com/tidwall/gjson v1.17.0 // indirect
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.0 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
Expand All @@ -118,12 +117,12 @@ require (
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/goleak v1.2.1 // indirect
go.uber.org/multierr v1.8.0 // indirect
golang.org/x/crypto v0.14.0 // indirect
golang.org/x/crypto v0.17.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/oauth2 v0.8.0 // indirect
golang.org/x/sync v0.2.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/tools v0.7.0 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
Expand Down
14 changes: 6 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1070,8 +1070,6 @@ github.com/opencontainers/selinux v1.8.0/go.mod h1:RScLhm78qiWa2gbVCcGkC7tCGdgk3
github.com/opencontainers/selinux v1.8.2/go.mod h1:MUIHuUEvKB1wtJjQdOyYRgOnLD2xAPP8dBsCoU0KuF8=
github.com/opencontainers/selinux v1.10.0/go.mod h1:2i0OySw99QjzBBQByd1Gr9gSjvuho1lHsJxIJ3gGbJI=
github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
github.com/ory/kratos-client-go v0.11.1 h1:2f+WZ94NReAUQlxdV/pp1ipScy5o5gYLHt2ThSNHHeA=
github.com/ory/kratos-client-go v0.11.1/go.mod h1:G31LzGZxgtMblK36qaTPWjG5OqnUWrncO1MjKkHsFUE=
github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
github.com/pelletier/go-toml v1.7.0/go.mod h1:vwGMzjaWMwyfHwgIBhI2YUM4fB6nL6lVAvS1LBMMhTE=
Expand Down Expand Up @@ -1414,8 +1412,8 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5y
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.0.0-20220314234659-1baeb1ce4c0b/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58=
golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc=
golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4=
golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k=
golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
Expand Down Expand Up @@ -1701,8 +1699,8 @@ golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
Expand All @@ -1720,8 +1718,8 @@ golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
Expand Down
118 changes: 0 additions & 118 deletions modules/core/handlers/kratos.go

This file was deleted.

1 change: 0 additions & 1 deletion modules/core/mod.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ func (coreModule) RegisterHandlers(g *echo.Group, container *dig.Container) erro
) {
handlers.NewOrgHandler(g, middManager, orgUsecase)
handlers.NewUserHandler(g, middManager, userUsecase)
handlers.NewKratosHookHandler(g, middManager, userUsecase)
handlers.NewAuthHandler(g, middManager, userUsecase, appConf)
})
}
17 changes: 0 additions & 17 deletions pkg/kratos/client.go

This file was deleted.

73 changes: 0 additions & 73 deletions pkg/middlewares/kratos.go

This file was deleted.

18 changes: 6 additions & 12 deletions pkg/middlewares/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@ import (
"github.com/dzungtran/echo-rest-api/pkg/authz"
"github.com/dzungtran/echo-rest-api/pkg/constants"
"github.com/dzungtran/echo-rest-api/pkg/contexts"
"github.com/dzungtran/echo-rest-api/pkg/kratos"
"github.com/dzungtran/echo-rest-api/pkg/utils"
"github.com/labstack/echo/v4"
ory "github.com/ory/kratos-client-go"
)

// MiddlewareManager ...
Expand All @@ -29,8 +27,7 @@ type MiddlewareManager struct {
orgRepo coreRepo.OrgRepository
projectRepo projectRepo.ProjectRepository

userUC usecases.UserUsecase
kratosClient *ory.APIClient
userUC usecases.UserUsecase
}

// NewMiddlewareManager will create new an MiddlewareManager object
Expand All @@ -45,21 +42,18 @@ func NewMiddlewareManager(
userUC usecases.UserUsecase,
) *MiddlewareManager {
return &MiddlewareManager{
appConf: appConf,
userRepo: userRepo,
userOrgRepo: userOrgRepo,
orgRepo: orgRepo,
userUC: userUC,
kratosClient: kratos.NewKratosSelfHostedClient(appConf.KratosApiEndpoint, appConf.Environment == "development"),
appConf: appConf,
userRepo: userRepo,
userOrgRepo: userOrgRepo,
orgRepo: orgRepo,
userUC: userUC,
}
}

func (m MiddlewareManager) Auth() echo.MiddlewareFunc {
return func(next echo.HandlerFunc) echo.HandlerFunc {

switch m.appConf.AuthProvider {
case "kratos":
return m.KratosAuth(next)
default:
// Default auth method
return m.FireBaseAuth(next)
Expand Down

0 comments on commit 2844eb2

Please sign in to comment.