Skip to content

Instantly share code, notes, and snippets.

@ambethia
Created December 13, 2009 03:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ambethia/255249 to your computer and use it in GitHub Desktop.
Save ambethia/255249 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
#
# auth-aloha.rb - OpenVPN auth script for Aloha
#
# Created by Jason Perry on 2009-12-12.
# Copyright (c) 2009 Gray's College Bookstore. All rights reserved.
#
# Usage:
# auth-user-pass-verify /path/to/auth-aloha.rb via-file
#
require 'net/http'
require 'net/https'
require 'cgi'
cred = File.read(ARGV.shift).split.map {|s| CGI.escape(s) }
http = Net::HTTP.new('aloha.graysbooks.com', 443)
http.use_ssl = true;
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
resp = http.post('/auth', ('email=%s&password=%s&to=vpn' % cred))
exit resp.code == '200' ? 0 : 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment