duo_security 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +12 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +36 -0
- data/Rakefile +9 -0
- data/bin/duo +20 -0
- data/data/ca-bundle.crt +3849 -0
- data/duo_security.gemspec +22 -0
- data/lib/duo_security/api.rb +82 -0
- data/lib/duo_security/attempt.rb +17 -0
- data/lib/duo_security/version.rb +3 -0
- data/lib/duo_security.rb +6 -0
- data/spec/duo_security/api_spec.rb +99 -0
- data/spec/duo_security/attempt_spec.rb +28 -0
- metadata +96 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
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
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
|