git.iko.soy/typeable/oauth2-proxy
on master help sign in
Merge pull request #38 from jehiah/release_38
d552effDan Lotterman
.gitignore+2
@@ -22,3 +22,5 @@ _cgo_export.*
22_testmain.go
22_testmain.go
23
23
24*.exe
24*.exe
25+dist
26+.godeps
.travis.yml+8−5
@@ -1,9 +1,12 @@
1language: go
1language: go
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
2−install:
8+ - ./gpm install
3− - go get github.com/bmizerany/assert
9+ - ./test.sh
4− - go get github.com/bitly/go-simplejson
5− - go get github.com/mreiferson/go-options
6− - go get github.com/BurntSushi/toml
7notifications:
10notifications:
8 email: false
11 email: false
9
12
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.
8[![Build Status](https://secure.travis-ci.org/bitly/google_auth_proxy.png?branch=master)](http://travis-ci.org/bitly/google_auth_proxy)
8[![Build Status](https://secure.travis-ci.org/bitly/google_auth_proxy.png?branch=master)](http://travis-ci.org/bitly/google_auth_proxy)
9
9
10
10
11+![sign_in_page](https://cloud.githubusercontent.com/assets/45028/4970624/7feb7dd8-6886-11e4-93e0-c9904af44ea8.png)
12+
11## Architecture
13## Architecture
12
14
13```
15```
@@ -22,8 +24,10 @@ individual accounts, or a whole google apps domain.
22
24
23## Installation
25## Installation
24
26
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)
27
31
28## OAuth Configuration
32## OAuth Configuration
29
33
contrib/google_auth_proxy.cfg.example+1−1
@@ -41,4 +41,4 @@
41# cookie_secret = ""
41# cookie_secret = ""
42# cookie_domain = ""
42# cookie_domain = ""
43# cookie_expire = "168h"
43# 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() {
37 flagSet.String("cookie-secret", "", "the seed string for secure cookies")
37 flagSet.String("cookie-secret", "", "the seed string for secure cookies")
38 flagSet.String("cookie-domain", "", "an optional cookie domain to force cookies to (ie: .yourcompany.com)*")
38 flagSet.String("cookie-domain", "", "an optional cookie domain to force cookies to (ie: .yourcompany.com)*")
39 flagSet.Duration("cookie-expire", time.Duration(168)*time.Hour, "expire timeframe for cookie")
39 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")
41
41
42 flagSet.Parse(os.Args[1:])
42 flagSet.Parse(os.Args[1:])
43
43
oauthproxy.go+7
@@ -55,6 +55,11 @@ func NewOauthProxy(opts *Options, validator func(string) bool) *OauthProxy {
55 redirectUrl.Path = oauthCallbackPath
55 redirectUrl.Path = oauthCallbackPath
56
56
57 log.Printf("OauthProxy configured for %s", opts.ClientID)
57 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)
58 return &OauthProxy{
63 return &OauthProxy{
59 CookieKey: "_oauthproxy",
64 CookieKey: "_oauthproxy",
60 CookieSeed: opts.CookieSecret,
65 CookieSeed: opts.CookieSecret,
@@ -229,10 +234,12 @@ func (p *OauthProxy) SignInPage(rw http.ResponseWriter, req *http.Request, code
229 SignInMessage string
234 SignInMessage string
230 Htpasswd bool
235 Htpasswd bool
231 Redirect string
236 Redirect string
237+ Version string
232 }{
238 }{
233 SignInMessage: p.SignInMessage,
239 SignInMessage: p.SignInMessage,
234 Htpasswd: p.HtpasswdFile != nil,
240 Htpasswd: p.HtpasswdFile != nil,
235 Redirect: req.URL.RequestURI(),
241 Redirect: req.URL.RequestURI(),
242+ Version: VERSION,
236 }
243 }
237 templates.ExecuteTemplate(rw, "sign_in.html", t)
244 templates.ExecuteTemplate(rw, "sign_in.html", t)
238}
245}
options.go+6−1
@@ -29,7 +29,12 @@ type Options struct {
29}
29}
30
30
31func NewOptions() *Options {
31func 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+ }
33}
38}
34
39
35func (o *Options) Validate() error {
40func (o *Options) Validate() error {
templates.go+20
@@ -76,6 +76,23 @@ func getTemplates() *template.Template {
76 margin:0;
76 margin:0;
77 box-sizing: border-box;
77 box-sizing: border-box;
78 }
78 }
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+ }
79 </style>
96 </style>
80</head>
97</head>
81<body>
98<body>
@@ -99,6 +116,9 @@ func getTemplates() *template.Template {
99 </form>
116 </form>
100 </div>
117 </div>
101 {{ end }}
118 {{ 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>
102</body>
122</body>
103</html>
123</html>
104{{end}}`)
124{{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 @@
1package main
1package main
2
2
3−const VERSION = "0.1.0"
3+const VERSION = "1.0"