Auth/OIDC: Update Issuer & WebDAV Dummy Dockerfiles #98 #782

This commit is contained in:
Michael Mayer 2021-12-18 14:58:57 +01:00
parent 20dbb90f5f
commit 4f5c326268
3 changed files with 31 additions and 10 deletions

View file

@ -1,11 +1,14 @@
FROM golang:1
##################################################### BUILD STAGE ######################################################
FROM golang:alpine AS build
# Move to working directory /app
WORKDIR /app
LABEL maintainer="Michael Mayer <hello@photoprism.app>"
ARG GOPROXY
ARG GODEBUG
# Move to working directory /app
WORKDIR /app
# Copy files and download dependency using go mod
COPY /docker/dummy/oidc/app/. .
RUN go mod download

View file

@ -6,47 +6,64 @@ import (
"crypto/sha256"
"log"
"net/http"
"github.com/gorilla/mux"
"os"
"caos-test-op/mock"
"github.com/caos/oidc/pkg/op"
"github.com/gorilla/mux"
)
func main() {
ctx := context.Background()
var port, issuer string
if port = os.Getenv("DUMMY_OIDC_PORT"); port == "" {
port = "9998"
}
if issuer = os.Getenv("DUMMY_OIDC_ISSUER"); issuer == "" {
issuer = "http://dummy-oidc:9998"
}
b := make([]byte, 32)
rand.Read(b)
cryptoKey := sha256.Sum256(b)
port := "9998"
config := &op.Config{
Issuer: "http://dummy-oidc:9998",
CryptoKey: sha256.Sum256(b),
Issuer: issuer,
CryptoKey: cryptoKey,
CodeMethodS256: true,
}
storage := mock.NewAuthStorage()
handler, err := op.NewOpenIDProvider(ctx, config, storage)
if err != nil {
log.Fatal(err)
}
router := handler.HttpHandler().(*mux.Router)
router.Methods("GET").Path("/login").HandlerFunc(HandleLogin)
server := &http.Server{
Addr: ":" + port,
Handler: router,
}
err = server.ListenAndServe()
if err != nil {
log.Fatal(err)
}
<-ctx.Done()
}
func HandleLogin(w http.ResponseWriter, r *http.Request) {
r.ParseForm()
requestId := r.Form.Get("id")
// simulate user login and retrieve a token that indicates a successfully logged-in user
usertoken := requestId + ":usertoken"

View file

@ -1,4 +1,5 @@
FROM golang:1
##################################################### BUILD STAGE ######################################################
FROM golang:alpine AS build
LABEL maintainer="Michael Mayer <hello@photoprism.app>"
@ -19,4 +20,4 @@ EXPOSE 80
COPY /docker/dummy/webdav/config.yml /webdav/config.yml
COPY /docker/dummy/webdav/files /webdav/files
CMD webdav -c /webdav/config.yml
CMD ["/go/bin/webdav", "-c", "/webdav/config.yml"]