twilioauth 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ twilioauth.yml
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm use 1.9.3@twilioauth --create
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source :rubygems
2
+
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,27 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ twilioauth (0.0.0)
5
+ active_support
6
+ twilio-ruby
7
+
8
+ GEM
9
+ remote: http://rubygems.org/
10
+ specs:
11
+ active_support (3.0.0)
12
+ activesupport (= 3.0.0)
13
+ activesupport (3.0.0)
14
+ builder (3.0.0)
15
+ jwt (0.1.5)
16
+ multi_json (>= 1.0)
17
+ multi_json (1.3.6)
18
+ twilio-ruby (3.7.1)
19
+ builder (>= 2.1.2)
20
+ jwt (>= 0.1.2)
21
+ multi_json (>= 1.3.0)
22
+
23
+ PLATFORMS
24
+ ruby
25
+
26
+ DEPENDENCIES
27
+ twilioauth!
data/lib/twilioauth.rb ADDED
@@ -0,0 +1,36 @@
1
+ require "twilio-ruby"
2
+ require 'active_support/secure_random'
3
+
4
+ module Twilioauth
5
+
6
+ class Connection
7
+
8
+ attr_accessor :client, :account
9
+
10
+ def initialize(account_sid, auth_token)
11
+ @client = Twilio::REST::Client.new account_sid, auth_token
12
+ @account = @client.account
13
+ end
14
+
15
+ def sms(message, to, from = default_number)
16
+ @client.account.sms.messages.create(
17
+ :from => from,
18
+ :to => to,
19
+ :body => message
20
+ )
21
+ end
22
+
23
+ def default_number
24
+ #retrieve the default number
25
+ @default_number ||= @account.incoming_phone_numbers.list.first.phone_number
26
+ end
27
+ end
28
+
29
+ def self.auth(number, options = {})
30
+ connection = Twilioauth::Connection.new(options[:account_sid], options[:auth_token])
31
+ newpin = ActiveSupport::SecureRandom.hex(3)
32
+ connection.sms(newpin, number)
33
+ return newpin
34
+ end
35
+
36
+ end
@@ -0,0 +1,26 @@
1
+ lib = File.expand_path('../lib/', __FILE__)
2
+ $:.unshift lib unless $:.include?(lib)
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = 'twilioauth'
6
+ s.version = '0.0.1'
7
+ s.date = '2012-08-08'
8
+ s.summary = "2 factor auth for twilio"
9
+ s.description = "2 factor auth for twilio"
10
+ s.authors = ["Kelly Mahan"]
11
+ s.email = 'kmahan@kmahan.com'
12
+ s.files = ["lib/twilioauth.rb"]
13
+ s.homepage = 'http://rubygems.org/gems/twilioauth'
14
+
15
+ s.files = `git ls-files`.split("\n")
16
+ #s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
+ s.require_path = 'lib'
18
+
19
+ s.requirements << "twilio-ruby"
20
+ s.requirements << "active_support"
21
+
22
+ s.add_dependency "twilio-ruby"
23
+ s.add_dependency "active_support"
24
+
25
+
26
+ end
metadata ADDED
@@ -0,0 +1,84 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: twilioauth
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Kelly Mahan
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-08-08 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: twilio-ruby
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: active_support
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ description: 2 factor auth for twilio
47
+ email: kmahan@kmahan.com
48
+ executables: []
49
+ extensions: []
50
+ extra_rdoc_files: []
51
+ files:
52
+ - .gitignore
53
+ - .rvmrc
54
+ - Gemfile
55
+ - Gemfile.lock
56
+ - lib/twilioauth.rb
57
+ - twilioauth.gemspec
58
+ homepage: http://rubygems.org/gems/twilioauth
59
+ licenses: []
60
+ post_install_message:
61
+ rdoc_options: []
62
+ require_paths:
63
+ - lib
64
+ required_ruby_version: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
+ none: false
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ requirements:
77
+ - twilio-ruby
78
+ - active_support
79
+ rubyforge_project:
80
+ rubygems_version: 1.8.24
81
+ signing_key:
82
+ specification_version: 3
83
+ summary: 2 factor auth for twilio
84
+ test_files: []