duo_security 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,12 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ doc/
8
+ lib/bundler/man
9
+ pkg
10
+ rdoc
11
+ tmp
12
+ fixtures/vcr/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in duo_security.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Marten Veldthuis
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,36 @@
1
+ # DuoSecurity
2
+
3
+ This gem provides an API for integrating with DuoSecurity's two-factor
4
+ authentication system. It also comes with a shell script that allows you to
5
+ plug this into other systems, for example a FreeRadius server.
6
+
7
+ ## Installation
8
+
9
+ $ gem install duo_security
10
+
11
+ ## Usage
12
+
13
+ The shell scripts depend upon three environment variables being set:
14
+
15
+ DUO_HOST=api-XXXXXXXX.duosecurity.com
16
+ DUO_SKEY=your_secret_key
17
+ DUO_IKEY=your_integration_key
18
+
19
+ ## Contributing
20
+
21
+ Running the tests also depends upon the above three environment variables to be
22
+ set to an account of your choosing. Running the tests performs actual requests
23
+ to the account, although for the sake of speed they are cached in the
24
+ `fixtures/vcr` folder after the first run.
25
+
26
+ When performing actual requests, the tests will tell you what you action you
27
+ need to take in the mobile application for the test case that's being executed
28
+ (e.g. approve).
29
+
30
+ The following workflow is advised:
31
+
32
+ 1. Fork it
33
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
34
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
35
+ 4. Push to the branch (`git push origin my-new-feature`)
36
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+ require 'rake/testtask'
4
+
5
+ Rake::TestTask.new do |t|
6
+ t.pattern = "spec/**/*_spec.rb"
7
+ end
8
+
9
+ task :default => :test
data/bin/duo ADDED
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'duo_security'
4
+
5
+ host = ENV.fetch("DUO_HOST")
6
+ skey = ENV.fetch("DUO_SKEY")
7
+ ikey = ENV.fetch("DUO_IKEY")
8
+ user = ARGV[0]
9
+
10
+ api = DuoSecurity::API.new(host, skey, ikey)
11
+ attempt = DuoSecurity::Attempt.new(api, user).login!
12
+
13
+ if attempt == true
14
+ puts "Successful login for #{user}"
15
+ exit 0
16
+ end
17
+
18
+ # Fall back to failure
19
+ puts "Failed login attempt for #{user}"
20
+ exit 1