duo-api 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d94b9975331db7555613be8c9d9530a781d8e165
4
+ data.tar.gz: 9a91f75be1618ec3f22997d3c5956374c0a487e3
5
+ SHA512:
6
+ metadata.gz: eaa86d28caf9535753db8ef94ca7b50a62151eeca3846ce67bfcf705b09ae8c8f5bd85dca02890aff8e8b58f2b29db60595256cd989d2bcb7a6ba1f5a58a8133
7
+ data.tar.gz: 61e9fc8c95f731abcde8e0807382f65d02415642b6550e0382a25c1d90e11670fd48b560e81f9b7235c988c4aafb2142d0715ea10f23e4f95f7f51ea0d968039
@@ -0,0 +1,35 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /test/tmp/
9
+ /test/version_tmp/
10
+ /tmp/
11
+
12
+ ## Specific to RubyMotion:
13
+ .dat*
14
+ .repl_history
15
+ build/
16
+
17
+ ## Documentation cache and generated files:
18
+ /.yardoc/
19
+ /_yardoc/
20
+ /doc/
21
+ /rdoc/
22
+
23
+ ## Environment normalisation:
24
+ /.bundle/
25
+ /vendor/bundle
26
+ /lib/bundler/man/
27
+
28
+ # for a library or gem, you might want to ignore these files since the code is
29
+ # intended to run in multiple environments; otherwise, check them in:
30
+ Gemfile.lock
31
+ .ruby-version
32
+ .ruby-gemset
33
+
34
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
35
+ .rvmrc
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,14 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.1
4
+ - 2.1.7
5
+ - 2.0.0
6
+ - 1.9.3
7
+ before_install: gem install bundler -v 1.10.6
8
+ matrix:
9
+ include:
10
+ - rvm: 1.8.7
11
+ gemfile: gemfiles/Gemfile.18
12
+ - rvm: ree
13
+ gemfile: gemfiles/Gemfile.18
14
+
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
@@ -0,0 +1,25 @@
1
+ Copyright (c) 2011, Duo Security, Inc.
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions
6
+ are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright
9
+ notice, this list of conditions and the following disclaimer.
10
+ 2. Redistributions in binary form must reproduce the above copyright
11
+ notice, this list of conditions and the following disclaimer in the
12
+ documentation and/or other materials provided with the distribution.
13
+ 3. The name of the author may not be used to endorse or promote products
14
+ derived from this software without specific prior written permission.
15
+
16
+ THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17
+ IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18
+ OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19
+ IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21
+ NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in duo-api.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Highrise HQ LLC
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,93 @@
1
+ # DuoApi [![Build Status](https://travis-ci.org/highrisehq/duo-api.svg)](https://travis-ci.org/highrisehq/duo-api)
2
+
3
+ A thin, zero depedency library for connecting to the Duo Auth API.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'duo-api'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ ```
16
+ $ bundle
17
+ ```
18
+
19
+ Or install it yourself as:
20
+
21
+ ```
22
+ $ gem install duo-api
23
+ ```
24
+
25
+ If you're for some reason using REE or 1.8.7, you must also install the `json` Gem.
26
+
27
+ ## Configuration
28
+
29
+ During app initialization:
30
+ ```ruby
31
+ require 'duo-api'
32
+ DuoApi.config do |config|
33
+ # Found on Duo Admin panel for the application you've set up
34
+ config.hostname = "api-xxxxx.duosecurity.com"
35
+ config.integration_key = "asdf"
36
+ config.secret_key = "asdf"
37
+
38
+ # ONLY for Duo Web
39
+ # Generate a somewhat long secret token (40+ characters).
40
+ # If you're using Rails, `Rails.application.secret_token` should suffice
41
+ # can also run `duo-api app_secret`
42
+ config.app_secret = "Long app secret"
43
+ end
44
+ ```
45
+
46
+ For Rails this would go in something like `config/initializers/duo.rb`.
47
+ Keep in mind, you likely don't want to store these keys in your repository.
48
+
49
+ ### Configuration Caveat
50
+
51
+ Upon completion of the general features we noticed that Duo needs separate
52
+ credentials for different APIs. This config is currently Global. We (or someone)
53
+ should be adding a way to switch between credentials or perhaps it would be best
54
+ to initialize a Client class for each credential set
55
+
56
+ ## Usage
57
+
58
+ ```ruby
59
+ response = DuoApi.get("/auth/v2/check")
60
+ response.success? # => true
61
+ response.body["response"]["time"] # => 1357020061
62
+
63
+ response = DuoApi.post("/auth/v2/preauth", :params => { :username => "jphenow" })
64
+ response.success? # => true
65
+ response.code # => "200"
66
+ response.body["response"]["result"] # => "auth"
67
+ response.message # => "Account is active"
68
+
69
+ response = DuoApi.post("/auth/v2/preauth")
70
+ response.success? # => false
71
+ response.code # => "400"
72
+ response.message # => "Missing required request parameters"
73
+ ```
74
+
75
+ See the Duo [API documentation](https://www.duosecurity.com/docs/authapi) for a full list of
76
+ available endpoints.
77
+
78
+
79
+ ## Development
80
+
81
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
82
+
83
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
84
+
85
+ ## Contributing
86
+
87
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/duo-api. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
88
+
89
+
90
+ ## License
91
+
92
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
93
+
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "duo-api"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'duo-api/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "duo-api"
8
+ spec.version = DuoApi::VERSION
9
+ spec.authors = ["Jon Phenow"]
10
+ spec.email = ["j.phenow@gmail.com"]
11
+
12
+ spec.summary = %q{Duo API helps you interact with the Duo 2-factor authentication service}
13
+ spec.description = %q{Simplify your API communications with Duo. Sign out-going requests, receive consistent responses, Sign web requests, and verify their responses }
14
+ spec.homepage = "https://github.com/highrisehq/duo-api"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.10"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_development_dependency "rspec"
25
+ end
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ command = ARGV.first
4
+ if command == "app_secret"
5
+ require 'digest/sha1'
6
+ puts Digest::SHA1.hexdigest((0...32).map { ('A'..'z').to_a[rand(52)] }.join)
7
+ else
8
+ puts <<-S
9
+ Duo API helper
10
+
11
+ Commands:
12
+ \tapp_secret\t\tGenerates a token to use for app_secret in DuoApi configuration
13
+ S
14
+ end
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in duo-api.gemspec
4
+ gemspec :path => ".."
5
+
6
+ gem "json"
@@ -0,0 +1,38 @@
1
+ require "duo-api/version"
2
+ require "duo-api/configuration"
3
+ require "duo-api/signature"
4
+ require "duo-api/request"
5
+
6
+ if RUBY_VERSION =~ /1\.8/
7
+ begin
8
+ require "json"
9
+ rescue
10
+ raise "you need to install the json Gem for Ruby 1.8.7"
11
+ end
12
+ end
13
+
14
+ module DuoApi
15
+ InvalidConfiguration = Class.new(StandardError)
16
+
17
+ def self.config
18
+ @config ||= Configuration.new
19
+ yield @config if block_given?
20
+ @config
21
+ end
22
+
23
+ def self.get(path, options = {})
24
+ Request.request(path, { :method => "GET" }.merge(options))
25
+ end
26
+
27
+ def self.post(path, options = {})
28
+ Request.request(path, { :method => "POST" }.merge(options))
29
+ end
30
+
31
+ def self.sign(user_key)
32
+ Signature.sign(user_key)
33
+ end
34
+
35
+ def self.verify(signed_response)
36
+ Signature.verify(signed_response)
37
+ end
38
+ end
@@ -0,0 +1,4 @@
1
+ module DuoApi
2
+ class Configuration < Struct.new(:hostname, :integration_key, :secret_key, :app_secret)
3
+ end
4
+ end
@@ -0,0 +1,10 @@
1
+ require 'openssl'
2
+ module DuoApi
3
+ module Digesting
4
+ DIGEST = OpenSSL::Digest.new("sha1")
5
+
6
+ def digest(key, text)
7
+ OpenSSL::HMAC.hexdigest(DIGEST, key, text)
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,44 @@
1
+ require 'time'
2
+ module DuoApi
3
+ class HeaderSignature
4
+ extend Util
5
+ include Util
6
+ include Digesting
7
+
8
+ attr_reader :method
9
+ attr_reader :path
10
+ attr_reader :query_body_string
11
+
12
+ def initialize(method, path, query_body_string)
13
+ @method = method
14
+ @path = path
15
+ @query_body_string = query_body_string
16
+ end
17
+
18
+ def basic_auth
19
+ username = DuoApi.config.integration_key
20
+ password = digest(config.secret_key, body)
21
+
22
+ [username, password]
23
+ end
24
+
25
+ def date_header
26
+ @date_header ||= Time.now.utc.rfc2822
27
+ end
28
+
29
+ private
30
+
31
+ def body
32
+ components = [date_header]
33
+ components << method
34
+ components << hostname
35
+ components << path
36
+ components << query_body_string
37
+ components.join("\n")
38
+ end
39
+
40
+ def hostname
41
+ DuoApi.config.hostname
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,93 @@
1
+ require "net/http"
2
+ require "time"
3
+ require "duo-api/header_signature"
4
+ require "duo-api/response"
5
+ require "duo-api/util"
6
+
7
+ module DuoApi
8
+ class Request
9
+ extend Util
10
+ include Util
11
+
12
+ def self.request(path, options = {})
13
+ options = stringify_hash(options)
14
+ hostname = options["hostname"] || DuoApi.config.hostname
15
+ instance = new(options["method"], hostname, path, options["params"], options["headers"])
16
+ instance.run
17
+ end
18
+
19
+ attr_reader :method
20
+ attr_reader :signature
21
+ attr_reader :query_string
22
+ attr_reader :headers
23
+ attr_reader :uri
24
+
25
+ def initialize(method, hostname, path, params, headers)
26
+ @method = method.to_s.upcase
27
+ @method = "GET" if @method.length == 0
28
+ hostname = hostname.to_s.downcase.sub(/\/\z/, "")
29
+ path = "/#{path.to_s.sub(/\A\//, "")}"
30
+
31
+ params = stringify_hash(params)
32
+ @query_string = params.
33
+ sort_by { |k| k }.
34
+ map {|k,v| "#{URI.encode(k.to_s)}=#{URI.encode(v.to_s)}" }.
35
+ join("&")
36
+
37
+ @signature = HeaderSignature.new(method, path, query_string)
38
+
39
+ @headers = stringify_hash(headers)
40
+ @headers["Date"] = signature.date_header
41
+
42
+ uri_suffix = "?#{query_string}" if use_query_string? && params.length > 0
43
+ @uri = URI.parse("https://#{hostname}#{path}#{uri_suffix}")
44
+ end
45
+
46
+ def run
47
+ Response.new(http.request(build))
48
+ end
49
+
50
+ def inspect
51
+ inspects = "#<DuoApi::Request Method:#{method} URI:\"#{uri}\""
52
+ inspects << " Body:\"#{query_string}\"" if !use_query_string?
53
+ inspects << " Headers:#{headers.inspect}"
54
+ inspects << " BasicAuth:#{signature.basic_auth.inspect}"
55
+ inspects << ">"
56
+ inspects
57
+ end
58
+
59
+ private
60
+
61
+ def build
62
+ request = request_class.new(uri.request_uri)
63
+ request.basic_auth(*signature.basic_auth)
64
+ headers.each { |header, value| request[header] = value }
65
+
66
+ if !use_query_string?
67
+ request.body = query_string
68
+ request.content_type = 'application/x-www-form-urlencoded'
69
+ end
70
+ request
71
+ end
72
+
73
+ def http
74
+ @http ||= Net::HTTP.new(uri.host, uri.port).tap { |http|
75
+ http.use_ssl = true
76
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
77
+ }
78
+ end
79
+
80
+ def use_query_string?
81
+ method == "GET"
82
+ end
83
+
84
+ def request_class
85
+ case method
86
+ when "GET"
87
+ Net::HTTP::Get
88
+ when "POST"
89
+ Net::HTTP::Post
90
+ end
91
+ end
92
+ end
93
+ end
@@ -0,0 +1,64 @@
1
+ require "json"
2
+
3
+ module DuoApi
4
+ class Response
5
+ attr_reader :http_response
6
+
7
+ def initialize(http_response)
8
+ @http_response = http_response
9
+ end
10
+
11
+ def body
12
+ @body ||=
13
+ if json?
14
+ JSON.parse(http_response.body)
15
+ else
16
+ raw_body
17
+ end
18
+ end
19
+
20
+ def message
21
+ if json?
22
+ if body["response"] && body["response"]["status_msg"]
23
+ body["response"]["status_msg"]
24
+ elsif body["message"]
25
+ body["message"]
26
+ end
27
+ end
28
+ end
29
+
30
+ def success?
31
+ code == "200"
32
+ end
33
+
34
+ def unauthorized?
35
+ code == "401"
36
+ end
37
+
38
+ def code
39
+ http_response.code.to_s
40
+ end
41
+
42
+ def raw_body
43
+ http_response.body
44
+ end
45
+
46
+ def content_type
47
+ http_response.content_type
48
+ end
49
+
50
+ def json?
51
+ content_type == "application/json"
52
+ end
53
+
54
+ def inspect
55
+ inspects = "#<DuoApi::Response"
56
+ inspects << " Content-Type:\"#{content_type}\""
57
+ inspects << " Code:\"#{code}\""
58
+ inspects << " Message:\"#{message}\""
59
+ inspects << " Body:#{json? ? body.inspect : "\"#{body}\""}"
60
+ inspects << ">"
61
+ inspects
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,89 @@
1
+ require "base64"
2
+ require "duo-api/util"
3
+ require "duo-api/digesting"
4
+
5
+ # Parts of this code were derived from https://github.com/duosecurity/duo_ruby
6
+ # For Licensing see https://github.com/highrisehq/duo-api/blob/master/Duo-License
7
+ module DuoApi
8
+ class Signature
9
+ extend Util
10
+ extend Digesting
11
+
12
+ DUO_PREFIX = 'TX'
13
+ APP_PREFIX = 'APP'
14
+ AUTH_PREFIX = 'AUTH'
15
+
16
+
17
+ DUO_EXPIRE = 300
18
+ APP_EXPIRE = 3600
19
+
20
+ ERR_USER = error_with_message('The user_key passed to sign with is invalid.')
21
+
22
+ def self.sign(user_key)
23
+ raise ERR_USER if !user_key || user_key.to_s.length == 0 if user_key.include?('|')
24
+ if config.integration_key.to_s.length == 0 ||
25
+ config.secret_key.to_s.length == 0 ||
26
+ config.app_secret.to_s.length == 0
27
+ raise InvalidConfiguration, "your DuoApi doesn't seem to be configured properly"
28
+ end
29
+
30
+ vals = [user_key.to_s, config.integration_key]
31
+
32
+ duo_sig = sign_values(config.secret_key, vals, DUO_PREFIX, DUO_EXPIRE)
33
+ app_sig = sign_values(config.app_secret, vals, APP_PREFIX, APP_EXPIRE)
34
+
35
+ return [duo_sig, app_sig].join(':')
36
+ end
37
+
38
+ def self.verify(signed_response)
39
+ auth_sig, app_sig = signed_response.to_s.split(':')
40
+ auth_user = parse_vals(config.secret_key, auth_sig, AUTH_PREFIX)
41
+ app_user = parse_vals(config.app_secret, app_sig, APP_PREFIX)
42
+
43
+ return nil if auth_user != app_user
44
+
45
+ return auth_user
46
+ end
47
+
48
+ private
49
+
50
+ def self.parse_vals(key, val, prefix)
51
+ ts = Time.now.to_i
52
+
53
+ parts = val.to_s.split('|')
54
+ return nil if parts.length != 3
55
+ u_prefix, u_b64, u_sig = parts
56
+
57
+ sig = digest(key, [u_prefix, u_b64].join('|'))
58
+ sig = sig.to_s.strip
59
+ u_sig = u_sig.to_s.strip
60
+
61
+ return nil if digest(key, sig) != digest(key, u_sig)
62
+
63
+ return nil if u_prefix != prefix
64
+
65
+ cookie_parts = Base64.decode64(u_b64).to_s.split('|')
66
+ return nil if cookie_parts.length != 3
67
+ user, u_ikey, exp = cookie_parts
68
+
69
+ return nil if u_ikey != config.integration_key
70
+
71
+ return nil if ts >= exp.to_i
72
+
73
+ return user
74
+ end
75
+
76
+ def self.sign_values(key, values, prefix, expiration)
77
+ exp = Time.now.to_i + expiration
78
+
79
+ val_list = values + [exp]
80
+ val = val_list.join('|')
81
+
82
+ b64 = Base64.encode64(val).gsub(/\n/,'')
83
+ cookie = prefix + '|' + b64
84
+
85
+ sig = digest(key, cookie)
86
+ return [cookie, sig].join('|')
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,24 @@
1
+ module DuoApi
2
+ module Util
3
+ DuoApiError = Class.new(StandardError)
4
+
5
+ def stringify_hash(hash)
6
+ hash ||= {}
7
+ Hash[hash.map { |k, v| [k.to_s, v] }]
8
+ end
9
+
10
+ def config
11
+ DuoApi.config
12
+ end
13
+
14
+ def error_with_message(message)
15
+ klass = Class.new(DuoApiError)
16
+ klass.send :define_method, :initialize do |*msg|
17
+ msg = msg.first
18
+ msg ||= message
19
+ super msg
20
+ end
21
+ klass
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,3 @@
1
+ module DuoApi
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1 @@
1
+ require "duo-api"
metadata ADDED
@@ -0,0 +1,112 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: duo-api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Jon Phenow
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-11-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: 'Simplify your API communications with Duo. Sign out-going requests,
56
+ receive consistent responses, Sign web requests, and verify their responses '
57
+ email:
58
+ - j.phenow@gmail.com
59
+ executables:
60
+ - duo-api
61
+ extensions: []
62
+ extra_rdoc_files: []
63
+ files:
64
+ - ".gitignore"
65
+ - ".rspec"
66
+ - ".travis.yml"
67
+ - CODE_OF_CONDUCT.md
68
+ - Duo-License
69
+ - Gemfile
70
+ - LICENSE.txt
71
+ - README.md
72
+ - Rakefile
73
+ - bin/console
74
+ - bin/setup
75
+ - duo-api.gemspec
76
+ - exe/duo-api
77
+ - gemfiles/Gemfile.18
78
+ - lib/duo-api.rb
79
+ - lib/duo-api/configuration.rb
80
+ - lib/duo-api/digesting.rb
81
+ - lib/duo-api/header_signature.rb
82
+ - lib/duo-api/request.rb
83
+ - lib/duo-api/response.rb
84
+ - lib/duo-api/signature.rb
85
+ - lib/duo-api/util.rb
86
+ - lib/duo-api/version.rb
87
+ - lib/duo_api.rb
88
+ homepage: https://github.com/highrisehq/duo-api
89
+ licenses:
90
+ - MIT
91
+ metadata: {}
92
+ post_install_message:
93
+ rdoc_options: []
94
+ require_paths:
95
+ - lib
96
+ required_ruby_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ required_rubygems_version: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
106
+ requirements: []
107
+ rubyforge_project:
108
+ rubygems_version: 2.4.5
109
+ signing_key:
110
+ specification_version: 4
111
+ summary: Duo API helps you interact with the Duo 2-factor authentication service
112
+ test_files: []