Compare commits
No commits in common. "b4e762143951f561d250009fb37d123e9f166340" and "3bcc903be2147206adf5c55aa683dab5f1bf82ff" have entirely different histories.
b4e7621439
...
3bcc903be2
|
@ -0,0 +1,59 @@
|
||||||
|
name: Build/Test/Push
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- v3
|
||||||
|
- devel
|
||||||
|
- main
|
||||||
|
tags:
|
||||||
|
- 'v*.*.*'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
name: Test
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Install Go
|
||||||
|
uses: actions/setup-go@v2
|
||||||
|
with:
|
||||||
|
go-version: 1.13
|
||||||
|
|
||||||
|
- name: Retrieve code
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Test
|
||||||
|
run: go test ./...
|
||||||
|
|
||||||
|
publish:
|
||||||
|
name: Publish container images
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Retrieve code
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Gitlab variables
|
||||||
|
id: vars
|
||||||
|
run: build/gitlab-vars
|
||||||
|
|
||||||
|
- name: Login to GitHub Packages Docker Registry
|
||||||
|
uses: docker/login-action@v1
|
||||||
|
with:
|
||||||
|
registry: ghcr.io
|
||||||
|
username: ${{ github.repository_owner }}
|
||||||
|
password: ${{ secrets.CR_PAT }}
|
||||||
|
|
||||||
|
# Currently required, because buildx doesn't support auto-push from docker
|
||||||
|
- name: Set up builder
|
||||||
|
uses: docker/setup-buildx-action@v1
|
||||||
|
id: buildx
|
||||||
|
|
||||||
|
- name: Build and push image
|
||||||
|
uses: docker/build-push-action@v2
|
||||||
|
with:
|
||||||
|
builder: ${{ steps.buildx.outputs.name }}
|
||||||
|
file: build/Containerfile
|
||||||
|
push: true
|
||||||
|
platforms: linux/amd64,linux/arm64
|
||||||
|
tags: |
|
||||||
|
ghcr.io/nealey/simpleauth:${{ steps.vars.outputs.tag }}
|
|
@ -1,6 +1,3 @@
|
||||||
The canonical home for this project is
|
|
||||||
https://git.woozle.org/neale/simpleauth
|
|
||||||
|
|
||||||
# Simple Auth
|
# Simple Auth
|
||||||
|
|
||||||
All this does is present a login page.
|
All this does is present a login page.
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
FROM golang:1-alpine AS builder
|
||||||
|
|
||||||
|
WORKDIR /go/src/app
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
RUN go get -d -v ./...
|
||||||
|
RUN go install -v ./...
|
||||||
|
|
||||||
|
FROM alpine
|
||||||
|
COPY --from=builder /go/bin/simpleauth /bin
|
||||||
|
COPY --from=builder /go/src/app/static /static
|
||||||
|
ENTRYPOINT ["/bin/simpleauth"]
|
|
@ -1,17 +0,0 @@
|
||||||
FROM golang:1 AS build
|
|
||||||
WORKDIR /src
|
|
||||||
COPY go.* ./
|
|
||||||
COPY pkg ./pkg/
|
|
||||||
COPY cmd ./cmd/
|
|
||||||
RUN find
|
|
||||||
RUN go get ./...
|
|
||||||
RUN CGO_ENABLED=0 GOOS=linux go install ./...
|
|
||||||
|
|
||||||
FROM alpine AS runtime
|
|
||||||
WORKDIR /target
|
|
||||||
COPY web web
|
|
||||||
COPY --from=build /go/bin/ .
|
|
||||||
|
|
||||||
FROM scratch
|
|
||||||
COPY --from=runtime /target /
|
|
||||||
ENTRYPOINT ["/simpleauth"]
|
|
|
@ -1,9 +0,0 @@
|
||||||
#! /bin/sh
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
tag=git.woozle.org/neale/wallart-server
|
|
||||||
|
|
||||||
cd $(dirname $0)/..
|
|
||||||
docker build -t $tag -f build/Dockerfile .
|
|
||||||
docker push $tag
|
|
|
@ -14,7 +14,7 @@ import (
|
||||||
|
|
||||||
"github.com/GehirnInc/crypt"
|
"github.com/GehirnInc/crypt"
|
||||||
_ "github.com/GehirnInc/crypt/sha256_crypt"
|
_ "github.com/GehirnInc/crypt/sha256_crypt"
|
||||||
"git.woozle.org/neale/simpleauth/pkg/token"
|
"github.com/nealey/simpleauth/pkg/token"
|
||||||
)
|
)
|
||||||
|
|
||||||
const CookieName = "simpleauth-token"
|
const CookieName = "simpleauth-token"
|
||||||
|
@ -118,7 +118,7 @@ func main() {
|
||||||
)
|
)
|
||||||
htmlPath := flag.String(
|
htmlPath := flag.String(
|
||||||
"html",
|
"html",
|
||||||
"web",
|
"static",
|
||||||
"Path to HTML files",
|
"Path to HTML files",
|
||||||
)
|
)
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
7
go.mod
7
go.mod
|
@ -1,8 +1,5 @@
|
||||||
module git.woozle.org/neale/simpleauth
|
module github.com/nealey/simpleauth
|
||||||
|
|
||||||
go 1.13
|
go 1.13
|
||||||
|
|
||||||
require (
|
require github.com/GehirnInc/crypt v0.0.0-20200316065508-bb7000b8a962
|
||||||
github.com/GehirnInc/crypt v0.0.0-20200316065508-bb7000b8a962
|
|
||||||
github.com/stretchr/testify v1.8.1 // indirect
|
|
||||||
)
|
|
||||||
|
|
17
go.sum
17
go.sum
|
@ -1,19 +1,2 @@
|
||||||
github.com/GehirnInc/crypt v0.0.0-20200316065508-bb7000b8a962 h1:KeNholpO2xKjgaaSyd+DyQRrsQjhbSeS7qe4nEw8aQw=
|
github.com/GehirnInc/crypt v0.0.0-20200316065508-bb7000b8a962 h1:KeNholpO2xKjgaaSyd+DyQRrsQjhbSeS7qe4nEw8aQw=
|
||||||
github.com/GehirnInc/crypt v0.0.0-20200316065508-bb7000b8a962/go.mod h1:kC29dT1vFpj7py2OvG1khBdQpo3kInWP+6QipLbdngo=
|
github.com/GehirnInc/crypt v0.0.0-20200316065508-bb7000b8a962/go.mod h1:kC29dT1vFpj7py2OvG1khBdQpo3kInWP+6QipLbdngo=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
|
||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
|
||||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
|
||||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
|
||||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
|
||||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
|
||||||
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
|
|
||||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
|
||||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
|
||||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
|
||||||
|
|
|
@ -41,20 +41,15 @@
|
||||||
headers: headers,
|
headers: headers,
|
||||||
credentials: "same-origin",
|
credentials: "same-origin",
|
||||||
})
|
})
|
||||||
if (req.status != 401) {
|
|
||||||
let token = req.headers.get("X-Simpleauth-Token")
|
let token = req.headers.get("X-Simpleauth-Token")
|
||||||
if (token) {
|
if (token) {
|
||||||
// Set a cookie, just in case
|
// Set a cookie, just in case
|
||||||
let expiration = new Date()
|
document.cookie = `simpleauth-token=${token}; path=/; Secure; SameSite=Strict`
|
||||||
expiration.setFullYear(expiration.getFullYear() + 1)
|
location.reload(true)
|
||||||
document.cookie = `simpleauth-token=${token}; expires=${expiration.toUTCString()}; path=/; Secure; SameSite=Strict`
|
} else {
|
||||||
}
|
|
||||||
location.reload()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
console.log(req.headers)
|
|
||||||
error(req.statusText || "Authentication failed")
|
error(req.statusText || "Authentication failed")
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function init() {
|
async function init() {
|
||||||
document.querySelector("form").addEventListener("submit", login)
|
document.querySelector("form").addEventListener("submit", login)
|
Loading…
Reference in New Issue