git.iko.soy/typeable/oauth2-proxy
on master help sign in
Merge pull request #38 from jehiah/release_38

1.0 release

commitd552effc1e23ed086d6a3fe40ea746fb8e2e212e authorDan Lotterman <dan@bit.ly> dateMon 10 Nov 2014, 08:51 (12 years ago) parent3a1db8f1fa1494
12 files changed+91−11
.gitignore+2 .travis.yml+8−5 Godeps+4 README.md+6−2 contrib/google_auth_proxy.cfg.example+1−1 dist.sh+30 main.go+1−1 oauthproxy.go+7 options.go+6−1 templates.go+20 test.sh+5 version.go+1−1
.gitignore+2
@@ -22,3 +22,5 @@ _cgo_export.*
2222_testmain.go
2323
2424*.exe
25+dist
26+.godeps
.travis.yml+8−5
@@ -1,9 +1,12 @@
11language: go
2−install:
3− - go get github.com/bmizerany/assert
4− - go get github.com/bitly/go-simplejson
5− - go get github.com/mreiferson/go-options
6− - go get github.com/BurntSushi/toml
2+go:
3+ - 1.2.2
4+ - 1.3.3
5+script:
6+ - curl -s https://raw.githubusercontent.com/pote/gpm/v1.3.1/bin/gpm > gpm
7+ - chmod +x gpm
8+ - ./gpm install
9+ - ./test.sh
710notifications:
811 email: false
912
Godepsnew file+4
@@ -0,0 +1,4 @@
1+github.com/BurntSushi/toml 3883ac1ce943878302255f538fce319d23226223
2+github.com/bitly/go-simplejson 3378bdcb5cebedcbf8b5750edee28010f128fe24
3+github.com/mreiferson/go-options ee94b57f2fbf116075426f853e5abbcdfeca8b3d
4+github.com/bmizerany/assert e17e99893cb6509f428e1728281c2ad60a6b31e3
README.md+6−2
@@ -8,6 +8,8 @@ individual accounts, or a whole google apps domain.
88[![Build Status](https://secure.travis-ci.org/bitly/google_auth_proxy.png?branch=master)](http://travis-ci.org/bitly/google_auth_proxy)
99
1010
11+![sign_in_page](https://cloud.githubusercontent.com/assets/45028/4970624/7feb7dd8-6886-11e4-93e0-c9904af44ea8.png)
12+
1113## Architecture
1214
1315```
@@ -22,8 +24,10 @@ individual accounts, or a whole google apps domain.
2224
2325## Installation
2426
25−1. [Install Go](http://golang.org/doc/install)
26−2. `$ go get github.com/bitly/google_auth_proxy`. This should put the binary in `$GOROOT/bin`
27+1. Download [Prebuilt Binary](https://github.com/bitly/google_auth_proxy/releases) or build from `master` with `$ go get github.com/bitly/google_auth_proxy` which should put the binary in `$GOROOT/bin`
28+2. Register an OAuth Application with Google
29+3. Configure Google Auth Proxy using config file, command line options, or environment variables
30+4. Deploy behind a SSL endpoint (example provided for Nginx)
2731
2832## OAuth Configuration
2933
contrib/google_auth_proxy.cfg.example+1−1
@@ -41,4 +41,4 @@
4141# cookie_secret = ""
4242# cookie_domain = ""
4343# cookie_expire = "168h"
44−# cookie_https_only = false
44+# cookie_https_only = true
dist.shnew file+30
@@ -0,0 +1,30 @@
1+#!/bin/bash
2+
3+# build binary distributions for linux/amd64 and darwin/amd64
4+set -e
5+
6+DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
7+echo "working dir $DIR"
8+mkdir -p $DIR/dist
9+mkdir -p $DIR/.godeps
10+export GOPATH=$DIR/.godeps:$GOPATH
11+gpm install
12+
13+os=$(go env GOOS)
14+arch=$(go env GOARCH)
15+version=$(cat $DIR/version.go | grep "const VERSION" | awk '{print $NF}' | sed 's/"//g')
16+goversion=$(go version | awk '{print $3}')
17+
18+echo "... running tests"
19+./test.sh || exit 1
20+
21+for os in linux darwin; do
22+ echo "... building v$version for $os/$arch"
23+ BUILD=$(mktemp -d -t google_auth_proxy)
24+ TARGET="google_auth_proxy-$version.$os-$arch.$goversion"
25+ GOOS=$os GOARCH=$arch CGO_ENABLED=0 go build -o $BUILD/$TARGET/google_auth_proxy || exit 1
26+ pushd $BUILD
27+ tar czvf $TARGET.tar.gz $TARGET
28+ mv $TARGET.tar.gz $DIR/dist
29+ popd
30+done
main.go+1−1
@@ -37,7 +37,7 @@ func main() {
3737 flagSet.String("cookie-secret", "", "the seed string for secure cookies")
3838 flagSet.String("cookie-domain", "", "an optional cookie domain to force cookies to (ie: .yourcompany.com)*")
3939 flagSet.Duration("cookie-expire", time.Duration(168)*time.Hour, "expire timeframe for cookie")
40− flagSet.Bool("cookie-https-only", false, "set HTTPS only cookie")
40+ flagSet.Bool("cookie-https-only", true, "set HTTPS only cookie")
4141
4242 flagSet.Parse(os.Args[1:])
4343
oauthproxy.go+7
@@ -55,6 +55,11 @@ func NewOauthProxy(opts *Options, validator func(string) bool) *OauthProxy {
5555 redirectUrl.Path = oauthCallbackPath
5656
5757 log.Printf("OauthProxy configured for %s", opts.ClientID)
58+ domain := opts.CookieDomain
59+ if domain == "" {
60+ domain = "<default>"
61+ }
62+ log.Printf("Cookie settings: https_only: %v expiry: %s domain:%s", opts.CookieHttpsOnly, opts.CookieExpire, domain)
5863 return &OauthProxy{
5964 CookieKey: "_oauthproxy",
6065 CookieSeed: opts.CookieSecret,
@@ -229,10 +234,12 @@ func (p *OauthProxy) SignInPage(rw http.ResponseWriter, req *http.Request, code
229234 SignInMessage string
230235 Htpasswd bool
231236 Redirect string
237+ Version string
232238 }{
233239 SignInMessage: p.SignInMessage,
234240 Htpasswd: p.HtpasswdFile != nil,
235241 Redirect: req.URL.RequestURI(),
242+ Version: VERSION,
236243 }
237244 templates.ExecuteTemplate(rw, "sign_in.html", t)
238245}
options.go+6−1
@@ -29,7 +29,12 @@ type Options struct {
2929}
3030
3131func NewOptions() *Options {
32− return &Options{}
32+ return &Options{
33+ HttpAddress: "127.0.0.1:4180",
34+ CookieHttpsOnly: true,
35+ PassBasicAuth: true,
36+ CookieExpire: time.Duration(168) * time.Hour,
37+ }
3338}
3439
3540func (o *Options) Validate() error {
templates.go+20
@@ -76,6 +76,23 @@ func getTemplates() *template.Template {
7676 margin:0;
7777 box-sizing: border-box;
7878 }
79+ footer {
80+ display:block;
81+ font-size:10px;
82+ color:#aaa;
83+ text-align:center;
84+ margin-bottom:10px;
85+ }
86+ footer a {
87+ display:inline-block;
88+ height:25px;
89+ line-height:25px;
90+ color:#aaa;
91+ text-decoration:underline;
92+ }
93+ footer a:hover {
94+ color:#aaa;
95+ }
7996 </style>
8097</head>
8198<body>
@@ -99,6 +116,9 @@ func getTemplates() *template.Template {
99116 </form>
100117 </div>
101118 {{ end }}
119+ <footer>
120+ Secured with <a href="https://github.com/bitly/google_auth_proxy#google_auth_proxy">Google Auth Proxy</a> version {{.Version}}
121+ </footer>
102122</body>
103123</html>
104124{{end}}`)
test.shnew file+5
@@ -0,0 +1,5 @@
1+#!/bin/bash
2+set -e
3+
4+go test -timeout 60s ./...
5+GOMAXPROCS=4 go test -timeout 60s -race ./...
version.go+1−1
@@ -1,3 +1,3 @@
11package main
22
3−const VERSION = "0.1.0"
3+const VERSION = "1.0"