diff --git a/Makefile b/Makefile deleted file mode 100644 index e42acb7..0000000 --- a/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -BIN=guichet -SRC=main.go ssha.go profile.go admin.go invite.go directory.go picture.go -DOCKER=lxpz/guichet_amd64 - -all: $(BIN) - -$(BIN): $(SRC) - go get -d -v - go build -v -o $(BIN) - -$(BIN).static: $(SRC) - go get -d -v - CGO_ENABLED=0 GOOS=linux go build -a -v -o $(BIN).static - -docker: $(BIN).static - docker build -t $(DOCKER):$(TAG) . - docker push $(DOCKER):$(TAG) - docker tag $(DOCKER):$(TAG) $(DOCKER):latest - docker push $(DOCKER):latest diff --git a/README.md b/README.md index 483ea71..a21ca32 100644 --- a/README.md +++ b/README.md @@ -27,9 +27,23 @@ Guichet is licensed under the terms of the GPLv3. Guichet requires go 1.13 or later. -To build Guichet, clone this repository outside of your `$GOPATH`. -Then, run `make` in the root of the repo. +Development build: +``` +go build +``` + +Production build: + +``` +nix build +``` + +Production container: + +``` +docker run .#docker +``` ## Configuration of Guichet diff --git a/flake.nix b/flake.nix index 3b6ad3b..20b42b1 100644 --- a/flake.nix +++ b/flake.nix @@ -47,11 +47,20 @@ Entrypoint = "/bin/guichet"; }; }; + + docker = pkgs.writeScriptBin "guichet-docker" '' + #!/usr/bin/env bash + + set -euxo pipefail + docker load <$(nix build --print-out-paths .#container) + ''; + in { packages.x86_64-linux.guichet = guichet; packages.x86_64-linux.container = container; + packages.x86_64-linux.docker = docker; packages.x86_64-linux.default = guichet; - + devShell.x86_64-linux = pkgs.mkShell { nativeBuildInputs = [ pkgs.go pkgs.gomod2nix ]; }; }; } diff --git a/go.sum b/go.sum index 6543905..33f35c3 100644 --- a/go.sum +++ b/go.sum @@ -31,8 +31,6 @@ cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohl cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= -git.deuxfleurs.fr/garage-sdk/garage-admin-sdk-golang v0.0.0-20230131081355-c965fe7f7dc9 h1:ERg8KCpIKym98EOKa8Gq0NSBxsasD3sqb/R0gg1wOzU= -git.deuxfleurs.fr/garage-sdk/garage-admin-sdk-golang v0.0.0-20230131081355-c965fe7f7dc9/go.mod h1:TlSL6QVxozmdRaSgP6Akspi0HCJv4HAkkq3Dldru4GM= git.deuxfleurs.fr/garage-sdk/garage-admin-sdk-golang v0.0.0-20231128153612-8b81fae65e5e h1:h89CAh0qmUcGJykss/utXIw+yRGa3Gr6VyrZ5ZWN0kY= git.deuxfleurs.fr/garage-sdk/garage-admin-sdk-golang v0.0.0-20231128153612-8b81fae65e5e/go.mod h1:TlSL6QVxozmdRaSgP6Akspi0HCJv4HAkkq3Dldru4GM= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= diff --git a/integration/docker-compose.yml b/integration/docker-compose.yml index e44a723..13b39b6 100644 --- a/integration/docker-compose.yml +++ b/integration/docker-compose.yml @@ -21,7 +21,7 @@ services: garage: # sync with deuxfleurs/nixcfg/cluster/prod/app/garage/deploy/garage.hcl # to ensure compatibility with prod - image: superboum/garage:v1.0.0-rc1-hotfix-red-ftr-wquorum + image: dxflrs/garage:v1.99.1-internal ports: - "3900:3900" - "3902:3902" diff --git a/invite.go b/invite.go index 24e5fbe..cf67596 100644 --- a/invite.go +++ b/invite.go @@ -1,19 +1,15 @@ package main import ( - "bytes" "crypto/rand" "encoding/binary" "encoding/hex" "fmt" - "html/template" "log" "net/http" "regexp" "strings" - "github.com/emersion/go-sasl" - "github.com/emersion/go-smtp" "github.com/go-ldap/ldap/v3" "github.com/gorilla/mux" "golang.org/x/crypto/argon2" @@ -251,21 +247,11 @@ func handleInviteSendCode(w http.ResponseWriter, r *http.Request) { WebBaseAddress: config.WebAddress, } - if r.Method == "POST" { - r.ParseForm() - - choice := strings.Join(r.Form["choice"], "") - sendto := strings.Join(r.Form["sendto"], "") - - if choice == "display" || choice == "send" { - trySendCode(user, choice, sendto, data) - } - } - + tryGenerateInvitation(user, data) templateInviteSendCode.Execute(w, data) } -func trySendCode(user *LoggedUser, choice string, sendto string, data *SendCodeData) { +func tryGenerateInvitation(user *LoggedUser, data *SendCodeData) { // Generate code code, code_id, code_pw := genCode() @@ -286,43 +272,9 @@ func trySendCode(user *LoggedUser, choice string, sendto string, data *SendCodeD return } - // If we want to display it, do so - if choice == "display" { - data.Success = true - data.CodeDisplay = code - return - } - - // Otherwise, we are sending a mail - if !EMAIL_REGEXP.MatchString(sendto) { - data.ErrorInvalidEmail = true - return - } - - templateMail := template.Must(template.ParseFiles(templatePath + "/invite_mail.txt")) - buf := bytes.NewBuffer([]byte{}) - templateMail.Execute(buf, &CodeMailFields{ - To: sendto, - From: config.MailFrom, - InviteFrom: user.WelcomeName(), - Code: code, - WebBaseAddress: config.WebAddress, - }) - - log.Printf("Sending mail to: %s", sendto) - var auth sasl.Client = nil - if config.SMTPUsername != "" { - auth = sasl.NewPlainClient("", config.SMTPUsername, config.SMTPPassword) - } - err = smtp.SendMail(config.SMTPServer, auth, config.MailFrom, []string{sendto}, buf) - if err != nil { - data.ErrorMessage = err.Error() - return - } - log.Printf("Mail sent.") - data.Success = true - data.CodeSentTo = sendto + data.CodeDisplay = code + return } func genCode() (code string, code_id string, code_pw string) { diff --git a/templates/garage_website_edit.html b/templates/garage_website_edit.html index 880721f..8b58f1f 100644 --- a/templates/garage_website_edit.html +++ b/templates/garage_website_edit.html @@ -57,9 +57,9 @@
Vous devez éditer votre zone DNS, souvent gérée par votre bureau d'enregistrement, comme Gandi, pour la faire pointer vers Deuxfleurs. Si vous utilisez un sous domaine (eg. site.example.com
), une entrée CNAME
est appropriée :
site CNAME 3600 garage.deuxfleurs.fr.+
site CNAME 3600 global.site.deuxfleurs.fr.
Si vous utilisez la racine de votre nom de domaine (eg. example.com
, aussi appelée APEX), la solution dépend de votre fournisseur DNS, il vous faudra au choix une entrée ALIAS
ou CNAME
en fonction de ce que votre fournisseur supporte :
@ ALIAS 3600 garage.deuxfleurs.fr.+
@ ALIAS 3600 global.site.deuxfleurs.fr.
La première fois que vous chargerez votre site web, une erreur de certificat sera renvoyée. C'est normal, il faudra patienter quelques minutes le temps que le certificat se génère.
Première configuration :
+ ++sudo npm install -g dxfl +dxfl login ++ +
Pour déployer votre site contenu dans le dossier public
:
+dxfl deploy {{ .View.Name.Pretty }} ./public ++
Clé secrète | - [Afficher la clé secrète] + [Afficher la clé secrète] |
---|---|