Skip to content

Commit

Permalink
add service account middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
james03160927 committed Jul 7, 2024
1 parent 7b5c79a commit 89c465c
Show file tree
Hide file tree
Showing 27 changed files with 138 additions and 486 deletions.
42 changes: 21 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Registry CLI [Github](https://github.com/yoland68/comfy-cli)

Install Golang:

<https://go.dev/doc/install>
https://go.dev/doc/install

Install go packages

Expand Down Expand Up @@ -68,7 +68,7 @@ This should search all directories and run go generate. This will run all the co

Or manually run:

`go run -mod=mod entgo.io/ent/cmd/ent generate --feature sql/upsert --feature sql/lock --feature sql/modifier ./ent/schema`
`go run -mod=mod entgo.io/ent/cmd/ent generate --feature sql/upsert --feature sql/lock ./ent/schema`

### Generate Migration Files

Expand All @@ -93,7 +93,7 @@ Or manually run:

`export PATH="$PATH:$HOME/bin:$HOME/go/bin"`

<https://github.com/deepmap/oapi-codegen/issues/795>
https://github.com/deepmap/oapi-codegen/issues/795

`oapi-codegen --config drip/codegen.yaml openapi.yml`

Expand All @@ -113,7 +113,7 @@ For non Comfy-Org contributors, you can use your own hosted function or just avo

Usually in localdev, we use dreamboothy-dev Firebase project for authentication. This conflicts with our machine creation logic because all of those machine images are in dreamboothy. TODO(robinhuang): Figure out a solution for this. Either we replicate things in dreamboothy-dev, or we pass project information separately when creating machine images.

### Creating VM instance error
### Creating VM instance error:

**Example:**

Expand Down Expand Up @@ -158,23 +158,23 @@ In order to bypass authentication error, you can add make the following changes
package drip_middleware

func FirebaseMiddleware(entClient *ent.Client) echo.MiddlewareFunc {
return func(next echo.HandlerFunc) echo.HandlerFunc {
return func(ctx echo.Context) error {
userDetails := &UserDetails{
ID: "test-james-token-id",
Email: "[email protected]",
Name: "James",
}

authdCtx := context.WithValue(ctx.Request().Context(), UserContextKey, userDetails)
ctx.SetRequest(ctx.Request().WithContext(authdCtx))
newUserError := db.UpsertUser(ctx.Request().Context(), entClient, userDetails.ID, userDetails.Email, userDetails.Name)
if newUserError != nil {
log.Ctx(ctx).Info().Ctx(ctx.Request().Context()).Err(newUserError).Msg("error User upserted successfully.")
}
return next(ctx)
}
}
return func(next echo.HandlerFunc) echo.HandlerFunc {
return func(ctx echo.Context) error {
userDetails := &UserDetails{
ID: "test-james-token-id",
Email: "[email protected]",
Name: "James",
}

authdCtx := context.WithValue(ctx.Request().Context(), UserContextKey, userDetails)
ctx.SetRequest(ctx.Request().WithContext(authdCtx))
newUserError := db.UpsertUser(ctx.Request().Context(), entClient, userDetails.ID, userDetails.Email, userDetails.Name)
if newUserError != nil {
log.Ctx(ctx).Info().Ctx(ctx.Request().Context()).Err(newUserError).Msg("error User upserted successfully.")
}
return next(ctx)
}
}
}

```
Expand Down
12 changes: 0 additions & 12 deletions ent/ciworkflowresult_query.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 5 additions & 21 deletions ent/ciworkflowresult_update.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ent/generate.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package ent

//go:generate go run -mod=mod entgo.io/ent/cmd/ent generate --feature sql/upsert --feature sql/lock --feature sql/modifier ./schema
//go:generate go run -mod=mod entgo.io/ent/cmd/ent generate --feature sql/upsert --feature sql/lock ./schema
12 changes: 0 additions & 12 deletions ent/gitcommit_query.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 5 additions & 21 deletions ent/gitcommit_update.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 0 additions & 12 deletions ent/node_query.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 5 additions & 21 deletions ent/node_update.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 0 additions & 12 deletions ent/nodereview_query.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 89c465c

Please sign in to comment.