Skip to content
Snippets Groups Projects
Commit e00e2820 authored by Niall Sheridan's avatar Niall Sheridan
Browse files

Make template directory configurable

parent 7230bf79
No related branches found
No related tags found
No related merge requests found
...@@ -3,4 +3,6 @@ FROM golang:1.6 ...@@ -3,4 +3,6 @@ FROM golang:1.6
ADD . /go/src/github.com/nsheridan/cashier ADD . /go/src/github.com/nsheridan/cashier
RUN go install github.com/nsheridan/cashier/cmd/cashierd RUN go install github.com/nsheridan/cashier/cmd/cashierd
ONBUILD COPY . /cashier
WORKDIR /cashier
ENTRYPOINT /go/bin/cashierd ENTRYPOINT /go/bin/cashierd
...@@ -53,6 +53,13 @@ go get github.com/cashier/cmd/... ...@@ -53,6 +53,13 @@ go get github.com/cashier/cmd/...
2. Create a signing key with `ssh-keygen` and a [config.json](exampleconfig.json) 2. Create a signing key with `ssh-keygen` and a [config.json](exampleconfig.json)
3. Run the cashier server with `cashierd` and the cli with `cashier`. 3. Run the cashier server with `cashierd` and the cli with `cashier`.
## Using docker
1. Create a signing key with `ssh-keygen` and a [config.json](exampleconfig.json)
2. Run
```
docker run -it --rm -p 10000:10000 --name cashier -v $(pwd):/cashier nsheridan/cashier
```
# Configuration # Configuration
Configuration is divided into three sections: `server`, `auth`, and `ssh`. Configuration is divided into three sections: `server`, `auth`, and `ssh`.
......
...@@ -13,6 +13,7 @@ import ( ...@@ -13,6 +13,7 @@ import (
"log" "log"
"net/http" "net/http"
"os" "os"
"path"
"strings" "strings"
"time" "time"
...@@ -221,7 +222,7 @@ func main() { ...@@ -221,7 +222,7 @@ func main() {
ctx := &appContext{ ctx := &appContext{
cookiestore: sessions.NewCookieStore([]byte(config.Server.CookieSecret)), cookiestore: sessions.NewCookieStore([]byte(config.Server.CookieSecret)),
authprovider: authprovider, authprovider: authprovider,
views: template.Must(template.ParseGlob("templates/*")), views: template.Must(template.ParseGlob(path.Join(config.Server.TemplateDir, "*"))),
sshKeySigner: signer, sshKeySigner: signer,
} }
ctx.cookiestore.Options = &sessions.Options{ ctx.cookiestore.Options = &sessions.Options{
......
...@@ -4,7 +4,8 @@ ...@@ -4,7 +4,8 @@
"tls_key": "server.key", "tls_key": "server.key",
"tls_cert": "server.crt", "tls_cert": "server.crt",
"port": 443, "port": 443,
"cookie_secret": "supersecret" "cookie_secret": "supersecret",
"template_dir": "/go/src/github.com/nsheridan/cashier/templates"
}, },
"auth": { "auth": {
"provider": "google", "provider": "google",
......
...@@ -20,6 +20,7 @@ type Server struct { ...@@ -20,6 +20,7 @@ type Server struct {
TLSCert string `mapstructure:"tls_cert"` TLSCert string `mapstructure:"tls_cert"`
Port int `mapstructure:"port"` Port int `mapstructure:"port"`
CookieSecret string `mapstructure:"cookie_secret"` CookieSecret string `mapstructure:"cookie_secret"`
TemplateDir string `mapstructure:"template_dir"`
} }
// Auth holds the configuration specific to the OAuth provider. // Auth holds the configuration specific to the OAuth provider.
......
...@@ -22,6 +22,7 @@ func TestServerConfig(t *testing.T) { ...@@ -22,6 +22,7 @@ func TestServerConfig(t *testing.T) {
a.Equal(server.TLSCert, "server.crt") a.Equal(server.TLSCert, "server.crt")
a.Equal(server.Port, 443) a.Equal(server.Port, 443)
a.Equal(server.CookieSecret, "supersecret") a.Equal(server.CookieSecret, "supersecret")
a.Equal(server.TemplateDir, "templates")
} }
func TestAuthConfig(t *testing.T) { func TestAuthConfig(t *testing.T) {
......
...@@ -6,7 +6,8 @@ var ServerConfig = []byte(`{ ...@@ -6,7 +6,8 @@ var ServerConfig = []byte(`{
"tls_key": "server.key", "tls_key": "server.key",
"tls_cert": "server.crt", "tls_cert": "server.crt",
"port": 443, "port": 443,
"cookie_secret": "supersecret" "cookie_secret": "supersecret",
"template_dir": "templates"
} }
}`) }`)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment