Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ APP_OKTA_SYNC_RULES=[{"name":"sync-eng","enabled":true,"okta_group_pattern":"^gi
# slack configuration (optional)
APP_SLACK_TOKEN=xoxb-xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
APP_SLACK_CHANNEL=C01234ABCDE

# api gateway base path (optional, for lambda deployments with stage prefix)
# APP_BASE_PATH=v1
13 changes: 11 additions & 2 deletions cmd/lambda/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"encoding/json"
"fmt"
"log/slog"
"strings"
"sync"

awsevents "github.com/aws/aws-lambda-go/events"
Expand Down Expand Up @@ -57,11 +58,19 @@ func APIGatewayHandler(ctx context.Context, req awsevents.APIGatewayProxyRequest
logger.Debug("received api gateway request", slog.String("request", string(j)))
}

if req.Path == "/server/status" {
path := req.Path
if appInst.Config.BasePath != "" {
path = strings.TrimPrefix(path, appInst.Config.BasePath)
if path == "" {
path = "/"
}
}

if path == "/server/status" {
return handleServerStatus(ctx, req)
}

if req.Path == "/server/config" {
if path == "/server/config" {
return handleServerConfig(ctx, req)
}

Expand Down
11 changes: 11 additions & 0 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ type Config struct {
SlackToken string
SlackChannel string
SlackAPIURL string

BasePath string
}

var (
Expand Down Expand Up @@ -246,6 +248,12 @@ func NewConfigWithContext(ctx context.Context) (*Config, error) {

cfg.SlackEnabled = cfg.SlackToken != "" && cfg.SlackChannel != ""

basePath := os.Getenv("APP_BASE_PATH")
if basePath != "" {
basePath = "/" + strings.Trim(basePath, "/")
}
cfg.BasePath = basePath

orphanedUserNotifications, _ := strconv.ParseBool(os.Getenv("APP_OKTA_ORPHANED_USER_NOTIFICATIONS"))
if os.Getenv("APP_OKTA_ORPHANED_USER_NOTIFICATIONS") == "" {
orphanedUserNotifications = cfg.IsOktaSyncEnabled()
Expand Down Expand Up @@ -345,6 +353,8 @@ type RedactedConfig struct {
SlackToken string `json:"slack_token"`
SlackChannel string `json:"slack_channel"`
SlackAPIURL string `json:"slack_api_url"`

BasePath string `json:"base_path"`
}

// Redacted returns a copy of the config with secrets redacted.
Expand Down Expand Up @@ -386,5 +396,6 @@ func (c *Config) Redacted() RedactedConfig {
SlackToken: redact(c.SlackToken),
SlackChannel: c.SlackChannel,
SlackAPIURL: c.SlackAPIURL,
BasePath: c.BasePath,
}
}