Skip to content
Open
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
13 changes: 4 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,28 +1,23 @@
FROM golang:1.10-alpine as builder
FROM golang:1.21.1-alpine3.18 as builder

# Now we DO need these, for the auto-labeling of the image
ARG BUILD_DATE
ARG VCS_REF

# Good docker practice, plus we get microbadger badges
LABEL org.label-schema.build-date=$BUILD_DATE \
org.label-schema.vcs-url="https://github.com/funkypenguin/traefik-forward-auth.git" \
org.label-schema.vcs-url="https://github.com/cisarpavel/traefik-forward-auth.git" \
org.label-schema.vcs-ref=$VCS_REF \
org.label-schema.schema-version="2.2-r1"


# Setup
RUN mkdir /app
WORKDIR /app

# Add libraries
RUN apk add --no-cache git && \
go get "github.com/namsral/flag" && \
go get "github.com/sirupsen/logrus" && \
apk del git

# Copy & build
ADD . /app/
RUN go mod init main
RUN go mod tidy
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix nocgo -o /traefik-forward-auth .

# Copy into scratch container
Expand Down
8 changes: 5 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ func handler(w http.ResponseWriter, r *http.Request) {
// Set the CSRF cookie
http.SetCookie(w, fw.MakeCSRFCookie(r, nonce))
logger.Debug("Set CSRF cookie and redirecting to oidc login")
logger.Debug("uri.Path was %s",uri.Path)
logger.Debug("fw.Path was %s",fw.Path)
logger.Debug("uri.Path was %s", uri.Path)
logger.Debug("fw.Path was %s", fw.Path)

// Forward them on
http.Redirect(w, r, fw.GetLoginURL(r, nonce), http.StatusTemporaryRedirect)
Expand Down Expand Up @@ -142,13 +142,15 @@ func handleCallback(w http.ResponseWriter, r *http.Request, qs url.Values,
}

func getOidcConfig(oidc string) map[string]interface{} {
fmt.Printf("OIDC string %s\n", oidc)
uri, err := url.Parse(oidc)
if err != nil {
log.Fatal("failed to parse oidc string")
log.Fatal("failed to parse oidc string: %s", err)
}
uri.Path = path.Join(uri.Path, "/.well-known/openid-configuration")
res, err := http.Get(uri.String())
if err != nil {
log.Errorf("Error getting user: %s", err)
log.Fatal("failed to get oidc parametere from oidc connect")
}
body, err := ioutil.ReadAll(res.Body)
Expand Down