Permalink
Browse files

initial commit

  • Loading branch information...
0 parents commit 48681bd35c6527d932239dd452691bb0f797671e Ben Woodall committed Mar 29, 2012
Showing with 182 additions and 0 deletions.
  1. +3 −0 History.txt
  2. +8 −0 Manifest.txt
  3. +59 −0 README.txt
  4. +21 −0 Rakefile
  5. +33 −0 lib/splunk.rb
  6. +43 −0 lib/tpauth.rb
  7. +5 −0 spec/spec_helper.rb
  8. +8 −0 spec/tpauth_spec.rb
  9. +2 −0 test/test_tpauth.rb
@@ -0,0 +1,3 @@
+
+
+
@@ -0,0 +1,8 @@
+.autotest
+History.txt
+Manifest.txt
+README.txt
+Rakefile
+bin/tpauth
+lib/tpauth.rb
+test/test_tpauth.rb
@@ -0,0 +1,59 @@
+= tpauth
+
+== DESCRIPTION:
+
+This is a gem to request auth tokens and verify a users credintials.
+
+== SYNOPSIS:
+
+require 'tpauth'
+
+foo = Tpauth::Token.full('email address', 'password')
+
+== REQUIREMENTS:
+
+install tpauth gem
+
+== INSTALL:
+
+Once the repo is cloned to your machine:
+
+gem install tpauth/pkg/tpauth-0.7.4.gem
+
+== Upcoming Features:
+
+* Add the ability to set token duration
+* Return token only
+* Finish testing/spec
+
+== Contributing to tpauth
+
+* Start a feature/bugfix branch.
+* Commit and push until you are happy with your contribution.
+* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
+* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
+
+== LICENSE:
+
+(The MIT License)
+
+Copyright (c) 2012 Ben Woodall
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+'Software'), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,21 @@
+# -*- ruby -*-
+
+require 'rubygems'
+require 'hoe'
+
+# Hoe.plugin :compiler
+# Hoe.plugin :gem_prelude_sucks
+# Hoe.plugin :inline
+# Hoe.plugin :minitest
+# Hoe.plugin :racc
+# Hoe.plugin :rubyforge
+
+Hoe.spec 'splunk' do
+
+ developer('Ben Woodall', 'ben.woodall@theplatform.com')
+
+ # self.rubyforge_name = 'tpauthx' # if different than 'tpauth'
+end
+
+
+
@@ -0,0 +1,33 @@
+module Splunk
+
+ VERSION = '0.2.1'
+
+ require 'net/https'
+ require 'rubygems'
+ require 'hpricot'
+
+ class Auth
+ HOST = 'tpsplunk'
+ PORT = 8089
+
+ def splunk_ssl_post_request(path, data = nil, headers = nil)
+ http = Net::HTTP.new(HOST, PORT)
+ http.use_ssl = true
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
+ http.post(path, data, headers).body
+ end
+
+ def session_key
+ @session_key ||= load_session_key
+ end
+
+ def load_session_key(user, pass)
+ doc = Hpricot(splunk_ssl_post_request("/services/auth/login", "username=#{user}&password=#{pass}"))
+ (doc/"//sessionkey").inner_html
+ end
+
+ end
+
+client = Splunk::Auth.new
+out = client.load_session_key
+puts out
@@ -0,0 +1,43 @@
+module Tpauth
+
+ VERSION = '1.0.0'
+
+ require 'net/http'
+ require 'yajl'
+
+ class Token
+
+ # url for Admin Auth
+ @url = URI("https://identity.auth.theplatform.com/idm/web/Authentication/signIn?schema=1.0&form=json")
+
+ def self.full(username, password)
+
+ req = Net::HTTP::Get.new(@url.request_uri)
+ req.basic_auth("#{username}", "#{password}")
+
+ result = Net::HTTP.start(@url.hostname, @url.port, :use_ssl => @url.scheme == 'https') do |http|
+ http.request(req)
+ end
+
+ # t = Tpauth::Token.full('ben.woodall@theplatform.com', '')
+
+ Yajl::Parser.parse(result.body)
+
+ end
+
+ def self.solo(username, password)
+ # return only the token value
+ res = Tpauth::Token.full(username,password)
+
+
+
+ end
+
+ def self.is_valid?
+ # is the user submitted valid? Boolean response.
+ end
+
+ end
+
+end
+
@@ -0,0 +1,5 @@
+SPEC_DIR = File.dirname(__FILE__)
+lib_path = File.expand_path("#{SPEC_DIR}/../lib")
+$LOAD_PATH.unshift lib_path unless $LOAD_PATH.include?(lib_path)
+
+require 'splunk'
@@ -0,0 +1,8 @@
+require "splunk"
+
+describe Splunk, "example test" do
+ it "should have a test written for it" do
+ pending "WRITE TESTS"
+ end
+end
+
@@ -0,0 +1,2 @@
+class Tpauth < MiniTest::Unit::TestCase
+end

0 comments on commit 48681bd

Please sign in to comment.