diff options
| author | mo khan <mo@mokhan.ca> | 2025-05-15 12:37:37 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2025-05-15 12:37:37 -0600 |
| commit | 152ca573505fd89151d3cdf117c3f1bb3b05b9d9 (patch) | |
| tree | 8becf29c1c26fdcc2f5c21e6110a1f2db521e0a7 | |
| parent | ca3fb0f032ab338a10379807d97e0d31c3afca35 (diff) | |
refactor: remove unused environment variables
| -rw-r--r-- | .env | 3 | ||||
| -rw-r--r-- | .runway/env-production.yml | 2 | ||||
| -rw-r--r-- | .runway/env-staging.yml | 2 | ||||
| -rw-r--r-- | Dockerfile | 1 | ||||
| -rw-r--r-- | app/app.go | 4 | ||||
| -rw-r--r-- | app/init.go | 8 | ||||
| -rwxr-xr-x | bin/envoy.sh | 3 | ||||
| -rw-r--r-- | cmd/sparkled/main.go | 2 | ||||
| -rw-r--r-- | share/man/DEVELOPMENT.md | 2 | ||||
| -rw-r--r-- | test/integration/container_test.go | 2 |
10 files changed, 7 insertions, 22 deletions
@@ -1,8 +1,5 @@ APP_ENV=development -BIND_ADDR=:8080 HMAC_SESSION_SECRET=session_secret -HOST=localhost OAUTH_CLIENT_ID=client_id OAUTH_CLIENT_SECRET=client_secret -OAUTH_REDIRECT_URL=http://localhost:8080/session/callback OIDC_ISSUER=https://gitlab.com diff --git a/.runway/env-production.yml b/.runway/env-production.yml index 9c1f873..fd18897 100644 --- a/.runway/env-production.yml +++ b/.runway/env-production.yml @@ -1,5 +1,3 @@ APP_ENV: "production" -HOST: "sparkle.runway.gitlab.net" OAUTH_CLIENT_ID: "75656280b7ca60223b060b57c4eb98a8a324878531efeccafc1d25709dbee5c9" -OAUTH_REDIRECT_URL: "https://sparkle.runway.gitlab.net/session/callback" OIDC_ISSUER: "https://gitlab.com" diff --git a/.runway/env-staging.yml b/.runway/env-staging.yml index 66df510..7a1192f 100644 --- a/.runway/env-staging.yml +++ b/.runway/env-staging.yml @@ -1,5 +1,3 @@ APP_ENV: "production" -HOST: "sparkle.staging.runway.gitlab.net" OAUTH_CLIENT_ID: "786e37c8d2207d200f735379ad52579c452948222f9affc7a45e74bd7074ad3c" -OAUTH_REDIRECT_URL: "https://sparkle.staging.runway.gitlab.net/session/callback" OIDC_ISSUER: "https://staging.gitlab.com" @@ -6,7 +6,6 @@ COPY . ./ RUN go build -o /bin/sparkled ./cmd/sparkled/main.go FROM envoyproxy/envoy:v1.34-latest -ENV BIND_ADDR=":8080" EXPOSE 8080 9901 10000 WORKDIR /opt/sparkle/ RUN mkdir -p bin etc public @@ -4,7 +4,7 @@ import ( "net/http" "path/filepath" - xoidc "github.com/coreos/go-oidc/v3/oidc" + "github.com/coreos/go-oidc/v3/oidc" "github.com/rs/zerolog" "github.com/xlgmokha/x/pkg/ioc" "github.com/xlgmokha/x/pkg/log" @@ -38,7 +38,7 @@ func New(rootDir string) http.Handler { logger := ioc.MustResolve[*zerolog.Logger](ioc.Default) users := ioc.MustResolve[domain.Repository[*domain.User]](ioc.Default) chain := middleware.IDToken( - ioc.MustResolve[*xoidc.Provider](ioc.Default), + ioc.MustResolve[*oidc.Provider](ioc.Default), ioc.MustResolve[*oauth2.Config](ioc.Default), middleware.IDTokenFromSessionCookie, )(middleware.User(users)(mux)) diff --git a/app/init.go b/app/init.go index cb9680d..a087103 100644 --- a/app/init.go +++ b/app/init.go @@ -5,7 +5,7 @@ import ( "net/http" "os" - xoidc "github.com/coreos/go-oidc/v3/oidc" + "github.com/coreos/go-oidc/v3/oidc" "github.com/rs/zerolog" "github.com/xlgmokha/x/pkg/ioc" "github.com/xlgmokha/x/pkg/log" @@ -48,7 +48,7 @@ func init() { }, } }) - ioc.Register[*xoidc.Provider](ioc.Default, func() *xoidc.Provider { + ioc.Register[*oidc.Provider](ioc.Default, func() *oidc.Provider { ctx := context.WithValue(context.Background(), oauth2.HTTPClient, ioc.MustResolve[*http.Client](ioc.Default)) return web.NewOIDCProvider(ctx, cfg.OIDCIssuer, func(err error) { ioc.MustResolve[*zerolog.Logger](ioc.Default).Err(err).Send() @@ -59,8 +59,8 @@ func init() { ClientID: cfg.OAuthClientID, ClientSecret: cfg.OAuthClientSecret, RedirectURL: cfg.OAuthRedirectURL, - Endpoint: ioc.MustResolve[*xoidc.Provider](ioc.Default).Endpoint(), - Scopes: []string{xoidc.ScopeOpenID, "profile", "email"}, + Endpoint: ioc.MustResolve[*oidc.Provider](ioc.Default).Endpoint(), + Scopes: []string{oidc.ScopeOpenID, "profile", "email"}, } }) diff --git a/bin/envoy.sh b/bin/envoy.sh index 8690bd1..8fae7ec 100755 --- a/bin/envoy.sh +++ b/bin/envoy.sh @@ -17,12 +17,9 @@ if [ "$oidc_scheme" = "http" ]; then yaml=$(echo "$yaml" | sed -e "s/port_value: 443/port_value: $oidc_port/") fi -# I need an adult with access to vault to set this if [ -z "$OAUTH_CLIENT_SECRET" ]; then export OAUTH_CLIENT_SECRET="secret" fi - -# and this. if [ -z "$HMAC_SESSION_SECRET" ]; then export HMAC_SESSION_SECRET="$OAUTH_CLIENT_SECRET" fi diff --git a/cmd/sparkled/main.go b/cmd/sparkled/main.go index 7bec1b7..161e8c1 100644 --- a/cmd/sparkled/main.go +++ b/cmd/sparkled/main.go @@ -11,7 +11,7 @@ import ( ) func main() { - bindAddr := env.Fetch("BIND_ADDR", ":http") + bindAddr := env.Fetch("BIND_ADDR", ":8080") log.Printf("Listening on %v\n", bindAddr) log.Fatal(http.ListenAndServe( diff --git a/share/man/DEVELOPMENT.md b/share/man/DEVELOPMENT.md index 9d4eaf6..c3077a8 100644 --- a/share/man/DEVELOPMENT.md +++ b/share/man/DEVELOPMENT.md @@ -56,10 +56,8 @@ The following environment variables must be defined: | Variable Name | Description | | ---------------------- | ------------------------------------------------ | | `APP_ENV` | Sparkle environment (default: `development`) | -| `BIND_ADDR` | Address Sparkle listens on (default: `:8080`) | | `OAUTH_CLIENT_ID` | The client ID registered with GitLab IdP | | `OAUTH_CLIENT_SECRET` | The corresponding client secret | -| `OAUTH_REDIRECT_URL` | Redirect URI configured in your GitLab OAuth app | | `OIDC_ISSUER` | The issuer URL (e.g., `http://gdk.test:3000`) | You can refer to the `Dockerfile` in the root of this repository to determine the diff --git a/test/integration/container_test.go b/test/integration/container_test.go index b956250..4768c98 100644 --- a/test/integration/container_test.go +++ b/test/integration/container_test.go @@ -20,12 +20,10 @@ import ( func environmentVariables(srv *oidc.TestServer) map[string]string { return map[string]string{ "APP_ENV": "test", - "BIND_ADDR": ":8080", "DEBUG": env.Fetch("DEBUG", ""), "HMAC_SESSION_SECRET": "secret", "OAUTH_CLIENT_ID": srv.MockOIDC.ClientID, "OAUTH_CLIENT_SECRET": srv.MockOIDC.ClientSecret, - "OAUTH_REDIRECT_URL": "", "OIDC_ISSUER": srv.Issuer(), } } |
