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

Release Version Two

commit66a0484721a5804435a108edf8763bea7ddfbf3e authorJehiah Czebotar <jehiah@gmail.com> dateFri 12 Jun 2015, 13:12 (11 years ago) parent1946739d78aa13
9 files changed+27−34
.travis.yml+2−1 README.md+2−3 contrib/oauth2_proxy.cfg.example+2−2 dist.sh+1−1 main.go+2−3 oauthproxy.go+6−10 oauthproxy_test.go+3−3 options.go+8−10 version.go+1−1
.travis.yml+2−1
@@ -3,10 +3,11 @@ go:
33 - 1.3.3
44 - 1.4.2
55script:
6− - curl -s https://raw.githubusercontent.com/pote/gpm/v1.3.1/bin/gpm > gpm
6+ - curl -s https://raw.githubusercontent.com/pote/gpm/v1.3.2/bin/gpm > gpm
77 - chmod +x gpm
88 - ./gpm install
99 - ./test.sh
10+sudo: false
1011notifications:
1112 email: false
1213
README.md+2−3
@@ -17,7 +17,7 @@ to validate accounts by email, domain or group.
1717
1818## Installation
1919
20−1. Download [Prebuilt Binary](https://github.com/bitly/oauth2_proxy/releases) (current release is `v1.1.1`) or build with `$ go get github.com/bitly/oauth2_proxy` which will put the binary in `$GOROOT/bin`
20+1. Download [Prebuilt Binary](https://github.com/bitly/oauth2_proxy/releases) (current release is `v2.0`) or build with `$ go get github.com/bitly/oauth2_proxy` which will put the binary in `$GOROOT/bin`
21212. Select a Provider and Register an OAuth Application with a Provider
22223. Configure OAuth2 Proxy using config file, command line options, or environment variables
23234. Configure SSL or Deploy behind a SSL endpoint (example provided for Nginx)
@@ -99,8 +99,7 @@ Usage of oauth2_proxy:
9999 -cookie-domain="": an optional cookie domain to force cookies to (ie: .yourcompany.com)*
100100 -cookie-expire=168h0m0s: expire timeframe for cookie
101101 -cookie-httponly=true: set HttpOnly cookie flag
102− -cookie-https-only=true: set secure (HTTPS) cookies (deprecated. use --cookie-secure setting)
103− -cookie-key="_oauth2proxy": the name of the cookie that the oauth_proxy creates
102+ -cookie-key="_oauth2_proxy": the name of the cookie that the oauth_proxy creates
104103 -cookie-refresh=0: refresh the cookie when less than this much time remains before expiration; 0 to disable
105104 -cookie-secret="": the seed string for secure cookies
106105 -cookie-secure=true: set secure (HTTPS) cookie flag
contrib/oauth2_proxy.cfg.example+2−2
@@ -54,7 +54,7 @@
5454# custom_templates_dir = ""
5555
5656## Cookie Settings
57−## Key - the cookie name
57+## Name - the cookie name
5858## Secret - the seed string for secure cookies; should be 16, 24, or 32 bytes
5959## for use with an AES cipher when cookie_refresh or pass_access_token
6060## is set
@@ -65,7 +65,7 @@
6565## Refresh revalidated the OAuth token to ensure it is still valid. ie: 24h
6666## Secure - secure cookies are only sent by the browser of a HTTPS connection (recommended)
6767## HttpOnly - httponly cookies are not readable by javascript (recommended)
68−# cookie_key = "_oauth2proxy"
68+# cookie_name = "_oauth2_proxy"
6969# cookie_secret = ""
7070# cookie_domain = ""
7171# cookie_expire = "168h"
dist.sh+1−1
@@ -18,7 +18,7 @@ goversion=$(go version | awk '{print $3}')
1818echo "... running tests"
1919./test.sh || exit 1
2020
21−for os in linux darwin; do
21+for os in windows linux darwin; do
2222 echo "... building v$version for $os/$arch"
2323 BUILD=$(mktemp -d -t oauth2_proxy)
2424 TARGET="oauth2_proxy-$version.$os-$arch.$goversion"
main.go+2−3
@@ -46,12 +46,11 @@ func main() {
4646 flagSet.String("custom-templates-dir", "", "path to custom html templates")
4747 flagSet.String("proxy-prefix", "/oauth2", "the url root path that this proxy should be nested under (e.g. /<oauth2>/sign_in)")
4848
49− flagSet.String("cookie-key", "_oauth2proxy", "the name of the cookie that the oauth_proxy creates")
49+ flagSet.String("cookie-name", "_oauth2_proxy", "the name of the cookie that the oauth_proxy creates")
5050 flagSet.String("cookie-secret", "", "the seed string for secure cookies")
5151 flagSet.String("cookie-domain", "", "an optional cookie domain to force cookies to (ie: .yourcompany.com)*")
5252 flagSet.Duration("cookie-expire", time.Duration(168)*time.Hour, "expire timeframe for cookie")
53− flagSet.Duration("cookie-refresh", time.Duration(0)*time.Hour, "refresh the cookie when less than this much time remains before expiration; 0 to disable")
54− flagSet.Bool("cookie-https-only", true, "set secure (HTTPS) cookies (deprecated. use --cookie-secure setting)")
53+ flagSet.Duration("cookie-refresh", time.Duration(0), "refresh the cookie when less than this much time remains before expiration; 0 to disable")
5554 flagSet.Bool("cookie-secure", true, "set secure (HTTPS) cookie flag")
5655 flagSet.Bool("cookie-httponly", true, "set HttpOnly cookie flag")
5756
oauthproxy.go+6−10
@@ -21,7 +21,7 @@ import (
2121
2222type OauthProxy struct {
2323 CookieSeed string
24− CookieKey string
24+ CookieName string
2525 CookieDomain string
2626 CookieSecure bool
2727 CookieHttpOnly bool
@@ -109,12 +109,8 @@ func NewOauthProxy(opts *Options, validator func(string) bool) *OauthProxy {
109109 if domain == "" {
110110 domain = "<default>"
111111 }
112− if !opts.CookieHttpsOnly {
113− log.Printf("Warning: cookie-https-only setting is deprecated and will be removed in a future version. use cookie-secure")
114− opts.CookieSecure = opts.CookieHttpsOnly
115− }
116112
117− log.Printf("Cookie settings: name:%s secure (https):%v httponly:%v expiry:%s domain:%s", opts.CookieKey, opts.CookieSecure, opts.CookieHttpOnly, opts.CookieExpire, domain)
113+ log.Printf("Cookie settings: name:%s secure(https):%v httponly:%v expiry:%s domain:%s", opts.CookieName, opts.CookieSecure, opts.CookieHttpOnly, opts.CookieExpire, domain)
118114
119115 var aes_cipher cipher.Block
120116 if opts.PassAccessToken || (opts.CookieRefresh != time.Duration(0)) {
@@ -127,7 +123,7 @@ func NewOauthProxy(opts *Options, validator func(string) bool) *OauthProxy {
127123 }
128124
129125 return &OauthProxy{
130− CookieKey: opts.CookieKey,
126+ CookieName: opts.CookieName,
131127 CookieSeed: opts.CookieSecret,
132128 CookieDomain: opts.CookieDomain,
133129 CookieSecure: opts.CookieSecure,
@@ -208,11 +204,11 @@ func (p *OauthProxy) MakeCookie(req *http.Request, value string, expiration time
208204 }
209205
210206 if value != "" {
211− value = signedCookieValue(p.CookieSeed, p.CookieKey, value)
207+ value = signedCookieValue(p.CookieSeed, p.CookieName, value)
212208 }
213209
214210 return &http.Cookie{
215− Name: p.CookieKey,
211+ Name: p.CookieName,
216212 Value: value,
217213 Path: "/",
218214 Domain: domain,
@@ -233,7 +229,7 @@ func (p *OauthProxy) SetCookie(rw http.ResponseWriter, req *http.Request, val st
233229func (p *OauthProxy) ProcessCookie(rw http.ResponseWriter, req *http.Request) (email, user, access_token string, ok bool) {
234230 var value string
235231 var timestamp time.Time
236− cookie, err := req.Cookie(p.CookieKey)
232+ cookie, err := req.Cookie(p.CookieName)
237233 if err == nil {
238234 value, timestamp, ok = validateCookie(cookie, p.CookieSeed)
239235 if ok {
oauthproxy_test.go+3−3
@@ -193,9 +193,9 @@ func (pat_test *PassAccessTokenTest) getCallbackEndpoint() (http_code int,
193193}
194194
195195func (pat_test *PassAccessTokenTest) getRootEndpoint(cookie string) (http_code int, access_token string) {
196− cookie_key := pat_test.proxy.CookieKey
196+ cookieName := pat_test.proxy.CookieName
197197 var value string
198− key_prefix := cookie_key + "="
198+ key_prefix := cookieName + "="
199199
200200 for _, field := range strings.Split(cookie, "; ") {
201201 value = strings.TrimPrefix(field, key_prefix)
@@ -214,7 +214,7 @@ func (pat_test *PassAccessTokenTest) getRootEndpoint(cookie string) (http_code i
214214 return 0, ""
215215 }
216216 req.AddCookie(&http.Cookie{
217− Name: cookie_key,
217+ Name: cookieName,
218218 Value: value,
219219 Path: "/",
220220 Expires: time.Now().Add(time.Duration(24)),
options.go+8−10
@@ -29,14 +29,13 @@ type Options struct {
2929 DisplayHtpasswdForm bool `flag:"display-htpasswd-form" cfg:"display_htpasswd_form"`
3030 CustomTemplatesDir string `flag:"custom-templates-dir" cfg:"custom_templates_dir"`
3131
32− CookieKey string `flag:"cookie-key" cfg:"cookie_key" env:"OAUTH2_PROXY_COOKIE_KEY"`
33− CookieSecret string `flag:"cookie-secret" cfg:"cookie_secret" env:"OAUTH2_PROXY_COOKIE_SECRET"`
34− CookieDomain string `flag:"cookie-domain" cfg:"cookie_domain" env:"OAUTH2_PROXY_COOKIE_DOMAIN"`
35− CookieExpire time.Duration `flag:"cookie-expire" cfg:"cookie_expire" env:"OAUTH2_PROXY_COOKIE_EXPIRE"`
36− CookieRefresh time.Duration `flag:"cookie-refresh" cfg:"cookie_refresh" env:"OAUTH2_PROXY_COOKIE_REFRESH"`
37− CookieHttpsOnly bool `flag:"cookie-https-only" cfg:"cookie_https_only"` // deprecated use cookie-secure
38− CookieSecure bool `flag:"cookie-secure" cfg:"cookie_secure"`
39− CookieHttpOnly bool `flag:"cookie-httponly" cfg:"cookie_httponly"`
32+ CookieName string `flag:"cookie-name" cfg:"cookie_name" env:"OAUTH2_PROXY_COOKIE_NAME"`
33+ CookieSecret string `flag:"cookie-secret" cfg:"cookie_secret" env:"OAUTH2_PROXY_COOKIE_SECRET"`
34+ CookieDomain string `flag:"cookie-domain" cfg:"cookie_domain" env:"OAUTH2_PROXY_COOKIE_DOMAIN"`
35+ CookieExpire time.Duration `flag:"cookie-expire" cfg:"cookie_expire" env:"OAUTH2_PROXY_COOKIE_EXPIRE"`
36+ CookieRefresh time.Duration `flag:"cookie-refresh" cfg:"cookie_refresh" env:"OAUTH2_PROXY_COOKIE_REFRESH"`
37+ CookieSecure bool `flag:"cookie-secure" cfg:"cookie_secure"`
38+ CookieHttpOnly bool `flag:"cookie-httponly" cfg:"cookie_httponly"`
4039
4140 Upstreams []string `flag:"upstream" cfg:"upstreams"`
4241 SkipAuthRegex []string `flag:"skip-auth-regex" cfg:"skip_auth_regex"`
@@ -68,8 +67,7 @@ func NewOptions() *Options {
6867 HttpAddress: "127.0.0.1:4180",
6968 HttpsAddress: ":443",
7069 DisplayHtpasswdForm: true,
71− CookieKey: "_oauthproxy",
72− CookieHttpsOnly: true,
70+ CookieName: "_oauth2_proxy",
7371 CookieSecure: true,
7472 CookieHttpOnly: true,
7573 CookieExpire: time.Duration(168) * time.Hour,
version.go+1−1
@@ -1,3 +1,3 @@
11package main
22
3−const VERSION = "1.1.1"
3+const VERSION = "2.0"