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
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,5 @@ USER nonroot
EXPOSE 8080

COPY --from=builder /go/bin/auth0-cas-server-go /auth0-cas-server-go
COPY --from=builder /build/templates /templates

ENTRYPOINT ["/auth0-cas-server-go", "-p=8080"]
3 changes: 3 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ func main() {
logger := slog.New(handler)
slog.SetDefault(logger)

// Initialize error template after logging is set up.
initErrorTemplate()

// Instrument Open Telemetry.
if !*noTrace {
// Start OTLP forwarder and register the global tracing provider.
Expand Down
10 changes: 7 additions & 3 deletions responses.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package main
// spell-checker:disable
import (
"context"
_ "embed"
"encoding/json"
"encoding/xml"
"errors"
Expand Down Expand Up @@ -80,6 +81,8 @@ var (

// spell-checker:enable

//go:embed templates/error.html
errorTemplateContent string
// errorTemplate is the HTML template for error pages.
errorTemplate *template.Template
)
Expand All @@ -91,10 +94,11 @@ type ErrorPageData struct {
ShowBackButton bool
}

// init initializes the error page template.
func init() {
// initErrorTemplate initializes the error page template from embedded content.
// This should be called from main() after logging is set up.
func initErrorTemplate() {
var err error
errorTemplate, err = template.ParseFiles("templates/error.html")
errorTemplate, err = template.New("error.html").Parse(errorTemplateContent)
if err != nil {
// Log error but don't fail - we'll fall back to plain text errors.
// This allows the service to start even if templates are missing.
Expand Down