From 734d963301326050f75cedaea4e86bc4cb70cc8d Mon Sep 17 00:00:00 2001 From: Andy Lo-A-Foe Date: Mon, 4 Oct 2010 23:21:17 +0200 Subject: [PATCH] Support HTTP proxy configuration for: * Google authenticator --- config.example.yml | 11 +++++++++++ lib/casserver/authenticators/google.rb | 6 +++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/config.example.yml b/config.example.yml index efa4206..044932c 100644 --- a/config.example.yml +++ b/config.example.yml @@ -43,6 +43,17 @@ ssl_cert: /path/to/your/ssl.pem # ssl_cert: ssl/cert.pem # ssl_key: ssl/key.pem +### +### Proxy support (Google, etc) +### +# If your server is behind a proxy you can uncomment the following lines in order +# to activate proxy support: +# +# proxy_host: your-proxy-server +# proxy_port: 8080 +# proxy_username: nil +# proxy_passsword: nil + # By default the login page will be available at the root path # (e.g. https://login.example.net/). The uri_path option lets you serve it from a diff --git a/lib/casserver/authenticators/google.rb b/lib/casserver/authenticators/google.rb index cd4c716..57fa1eb 100644 --- a/lib/casserver/authenticators/google.rb +++ b/lib/casserver/authenticators/google.rb @@ -22,7 +22,11 @@ class CASServer::Authenticators::Google < CASServer::Authenticators::Base } url = URI.parse('https://www.google.com/accounts/ClientLogin') - http = Net::HTTP.new(url.host, url.port) + if $CONF.proxy_host + http = Net::HTTP.Proxy($CONF.proxy_host, $CONF.proxy_port, $CONF.proxy_username, $CONF.proxy_password).new(url.host, url.port) + else + http = Net::HTTP.new(url.host, url.port) + end http.use_ssl = true # TODO: make the timeout configurable