Skip to content

Instantly share code, notes, and snippets.

@wellington1993
Forked from fredkelly/squid_auth.rb
Created March 16, 2016 11:54
Show Gist options
  • Save wellington1993/9b7c167965a869b4b06e to your computer and use it in GitHub Desktop.
Save wellington1993/9b7c167965a869b4b06e to your computer and use it in GitHub Desktop.
Gmail authentication helper for use with Squid proxy.
#!/usr/bin/env ruby
require 'net/imap'
while true
# open connection
imap = Net::IMAP.new('imap.googlemail.com', 993, true)
# get credentials
user, pass = $stdin.readline.split
# authenticate
begin
imap.login(user, pass)
puts "OK"
rescue Net::IMAP::Error => err
puts "ERR"
end
$stdout.flush
imap.disconnect
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment