Skip to content
Snippets Groups Projects
Commit 976327e4 authored by Nicolas PERNOUD's avatar Nicolas PERNOUD
Browse files

feat: first version

parent a593f304
Branches
No related tags found
No related merge requests found
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}/main.go",
"env": {},
"args": ["-http_port=8080"]
}
]
}
# Building...
FROM golang:alpine as server-builder
WORKDIR /server
RUN apk update && apk upgrade && \
apk add --no-cache bash git openssh build-base
ADD . .
RUN go get -d -v && \
go test ./... && \
go build -o server
# Running...
FROM alpine
WORKDIR /app
RUN apk update && apk add ca-certificates libcap
# ca-certificates for autocert (Let's Encrypt) and mailcap to get mime types for downloaded documents
COPY --from=server-builder /server/server /app
RUN setcap cap_net_bind_service=+ep server
ENTRYPOINT [ "./server"]
version: "2.4"
services:
cozy-oauth-proxy:
image: registry.forge.grandlyon.com/pocs/cozy/cozy-oauth-proxy
#image: cozy-oauth-proxy
container_name: cozy-oauth-proxy
restart: unless-stopped
mem_limit: 512m
user: "1000"
command: -http_port=8081
volumes:
- /etc/localtime:/etc/localtime:ro
ports:
- 8081:8081
go.mod 0 → 100644
main.go 0 → 100644
package main
import (
"flag"
"net/http"
"strconv"
"strings"
)
var (
httpPort = flag.Int("http_port", 80, "HTTP port to serve on (defaults to 80)")
)
func main() {
// Parse the flags
flag.Parse()
mux := http.NewServeMux()
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
query := r.URL.Query()
state := strings.Split(query.Get("state"), "-")[0]
host := r.Host
redir := "http://" + host + state
http.Redirect(w, r, redir, 302)
})
http.ListenAndServe(":"+strconv.Itoa(*httpPort), mux)
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment