diff options
| author | Leonardo Bishop <me@leonardobishop.net> | 2026-01-16 17:19:27 +0000 |
|---|---|---|
| committer | Leonardo Bishop <me@leonardobishop.net> | 2026-01-16 17:19:27 +0000 |
| commit | e6cbb8415490524034561102b6c9f03e92e4dae7 (patch) | |
| tree | 2012f04c11adf636bdd06ae37f5ef3efd7a645a0 /main.go | |
| parent | 8fc52adfdc705a1b05d3a0aef4d6e63f8ec0308d (diff) | |
Add OIDC auth
Diffstat (limited to 'main.go')
| -rw-r--r-- | main.go | 80 |
1 files changed, 18 insertions, 62 deletions
@@ -2,9 +2,11 @@ package main import ( "context" + _ "embed" "log/slog" "net/http" + "git.leonardobishop.net/instancer/pkg/auth" "git.leonardobishop.net/instancer/pkg/deployer" "git.leonardobishop.net/instancer/pkg/janitor" "git.leonardobishop.net/instancer/pkg/registry" @@ -21,71 +23,18 @@ type Config struct { ImagePrefix string `env:"IMAGE_PREFIX"` ProxyContainerName string `env:"PROXY_CONTAINER_NAME"` -} - -const startupMessage = ` - , . - , . . . - . . . . - what's the worst that i can say?... - . . - . . . - . . - . ...things are better if i stay... - . . . - . , - . , . . , - . . . - ! , - ! . - , . ^ - / \ . - . /___\ , - . |= =| , - . | | - | | , -, | | - | | . - | | - . . | | , - , | | . - | | - | | . - /|##!##|\ - . / |##!##| \ - / |##!##| \ , - | / ^ | ^ \ | - . | / ( | ) \ | , - , . |/ ( | ) \| - (( )) - (( : )) . - (( : )) - , (( )) . - . (( )) , - ( ) - . - . . . - , . , - - _ __ - ___| |_ / _| - / __| __| |_ - _ | (__| |_| _| - (_)_ __ ___| \___|\__|_|_ ___ ___ _ __ - | | '_ \/ __| __/ _` + "`" + ` | '_ \ / __/ _ \ '__| - | | | | \__ \ || (_| | | | | (_| __/ | - |_|_| |_|___/\__\__,_|_| |_|\___\___|_| -____^/\___^--____/\____O______________/\/\-- - /\^ ^ ^ ^ ^^ ^ '\ - -- - -- - - -- __ ___-- ^ ^ + OidcClientId string `env:"OIDC_CLIENT_ID"` + OidcClientSecret string `env:"OIDC_CLIENT_SECRET"` + OidcDiscoveryEndpoint string `env:"OIDC_DISCOVERY_ENDPOINT"` + OidcIdPName string `env:"OIDC_IDP_NAME" envDefault:"OIDC"` + OidcCallbackProtocol string `env:"OIDC_CALLBACK_PROTOCOL" envDefault:"https"` +} -` +//go:embed startup.txt +var startupMessage string func main() { - slog.Info(startupMessage) - var config Config if err := env.Parse(&config); err != nil { @@ -110,11 +59,18 @@ func main() { panic(err) } + oidcAuthProvider, err := auth.NewOIDCAuthProvider(config.OidcIdPName, config.OidcClientId, config.OidcClientSecret, config.OidcDiscoveryEndpoint, config.OidcCallbackProtocol+"://"+config.InstancerDomain+"/auth/callback") + if err != nil { + panic(err) + } + + slog.Info(startupMessage) + slog.Info("staring janitor job") go janitor.StartJanitor(context.Background(), &dockerDeployer) slog.Info("starting http server") - err = http.ListenAndServe(":8080", web.NewMux(®istryClient, &dockerDeployer)) + err = http.ListenAndServe(":8080", web.NewMux(®istryClient, &dockerDeployer, &oidcAuthProvider)) slog.Error("http server closing", "reason", err.Error()) slog.Info("so long and goodnight; so long and goodnight...") } |
