diff options
| author | mo khan <mo@mokhan.ca> | 2025-04-14 16:10:01 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2025-04-14 16:10:01 -0600 |
| commit | a8c6e1a4aee4a616cd7c73a39e579d7c9b63d720 (patch) | |
| tree | ae14a445308299be1addc51b1c4377735a9a8f52 | |
| parent | efc3c293f472a6993ca086fa335daf3719c6922a (diff) | |
feat: connect the sessions controller into the app
| -rw-r--r-- | Dockerfile | 2 | ||||
| -rw-r--r-- | Makefile | 2 | ||||
| -rw-r--r-- | app/app.go | 7 | ||||
| -rw-r--r-- | app/init.go | 21 |
4 files changed, 27 insertions, 5 deletions
@@ -4,12 +4,12 @@ ENV CGO_ENABLED=0 WORKDIR /app COPY . ./ RUN make build && mv ./sparkled /bin/sparkled -CMD ["/bin/sparkled"] FROM scratch ENV BIND_ADDR=":http" EXPOSE 80 WORKDIR /var/www/ +COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ COPY --from=build /bin/sparkled /bin/sparkled COPY --from=build /app/public /var/www/public CMD ["/bin/sparkled"] @@ -30,7 +30,7 @@ build-image: build-builder-image: @docker build --target build --tag $(IMAGE_TAG) . -run: build +run: clean build BIND_ADDR=:8080 ./sparkled run-image: build-image @@ -5,8 +5,8 @@ import ( "github.com/xlgmokha/x/pkg/ioc" "gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/app/controllers/health" + "gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/app/controllers/sessions" "gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/app/controllers/sparkles" - "gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/pkg/db" "gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/pkg/web" ) @@ -14,8 +14,9 @@ func New() http.Handler { mux := ioc.MustResolve[*http.ServeMux](ioc.Default) mountable := []web.Mountable{ - sparkles.New(ioc.MustResolve[db.Repository](ioc.Default)), - health.New(), + ioc.MustResolve[*sparkles.Controller](ioc.Default), + ioc.MustResolve[*sessions.Controller](ioc.Default), + ioc.MustResolve[*health.Controller](ioc.Default), } for _, m := range mountable { m.MountTo(mux) diff --git a/app/init.go b/app/init.go index 9ff7bec..9bffde8 100644 --- a/app/init.go +++ b/app/init.go @@ -1,12 +1,17 @@ package app import ( + "context" + "log" "net/http" + "github.com/xlgmokha/x/pkg/env" "github.com/xlgmokha/x/pkg/ioc" "gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/app/controllers/health" + "gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/app/controllers/sessions" "gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/app/controllers/sparkles" "gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/pkg/db" + "gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/pkg/oidc" ) func init() { @@ -22,4 +27,20 @@ func init() { ioc.Register[*health.Controller](ioc.Default, func() *health.Controller { return health.New() }) + ioc.RegisterSingleton[*oidc.OpenID](ioc.Default, func() *oidc.OpenID { + item, err := oidc.New( + context.Background(), + env.Fetch("OIDC_ISSUER", "https://gitlab.com"), + env.Fetch("OAUTH_CLIENT_ID", "client_id"), + env.Fetch("OAUTH_CLIENT_SECRET", "client_secret"), + env.Fetch("OAUTH_REDIRECT_URL", "https://localhost/session/callback"), + ) + if err != nil { + log.Fatal(err) + } + return item + }) + ioc.Register[*sessions.Controller](ioc.Default, func() *sessions.Controller { + return sessions.New(ioc.MustResolve[*oidc.OpenID](ioc.Default)) + }) } |
