duo_universal_ruby 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -3
- data/README.md +27 -19
- data/lib/duo_universal_ruby/client.rb +1 -1
- data/lib/duo_universal_ruby/version.rb +1 -1
- metadata +4 -4
- data/duo_universal_ruby.gemspec +0 -40
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f415b4d90a0f543d5467d2d704675a473fddeec021d04d674dcc1e93a94ca297
|
4
|
+
data.tar.gz: 8012aef8a3b2ac1f72ddf98fe1be7e2a8eb58d9d537ae56159fc0c7b2beed840
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f52dc63df5ad83ba272c5062d68d639860f3930cf16a6e2ef17e974b414ae5c21f6266a858a4ad28036e6a3b33dc232a62cb54b832e058a318b4b191b670362
|
7
|
+
data.tar.gz: 996e1231b11d551eda3efb9b9adf05f6d321fd32431cb986a6bbf89ded27176d4fb245cb0ba347376fa2a9645b15ced083689cd777084e922cc9157ccd67249f
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -19,7 +19,13 @@ If bundler is not being used to manage dependencies, install the gem by executin
|
|
19
19
|
## Usage
|
20
20
|
|
21
21
|
```ruby
|
22
|
-
|
22
|
+
# Replace fake DUO constant values with real values obtained from DUO
|
23
|
+
DUO_CLIENT_ID = "X" * 20
|
24
|
+
DUO_CLIENT_SECRET = "x" * 40
|
25
|
+
DUO_HOST = "api-xxxxxxxx.duosecurity.com"
|
26
|
+
DUO_REDIRECT_URI = "https://localhost/duo-callback"
|
27
|
+
|
28
|
+
client = DuoUniversalRuby::Client.new(
|
23
29
|
client_id: DUO_CLIENT_ID,
|
24
30
|
client_secret: DUO_CLIENT_SECRET,
|
25
31
|
api_host: DUO_HOST,
|
@@ -46,8 +52,11 @@ client.health_check
|
|
46
52
|
|
47
53
|
state = client.generate_state
|
48
54
|
# Random value that is checked after interactions to protect against CSRF attacks
|
49
|
-
|
50
|
-
|
55
|
+
|
56
|
+
username = "test@example.com"
|
57
|
+
# user authenticating with Duo
|
58
|
+
|
59
|
+
client.create_auth_url(username: username, state: state)
|
51
60
|
# Generate uri to Duo's prompt
|
52
61
|
# GET /oauth/v1/authorize
|
53
62
|
|
@@ -59,31 +68,30 @@ client.create_auth_url(username, state)
|
|
59
68
|
# Returns:
|
60
69
|
# Authorization uri to redirect to for the Duo prompt
|
61
70
|
|
62
|
-
# After a successful Duo
|
71
|
+
# After a successful Duo authentication, Duo redirects the user to the redirect_uri, e.g. /duo_callback with the params: duo_code and state
|
72
|
+
|
73
|
+
decoded_token = client.exchange_authorization_code_for_2fa_result(duo_code: duo_code, username: username)
|
74
|
+
# Exchange the duo_code for a token with Duo to determine
|
75
|
+
# if the auth was successful.
|
63
76
|
|
64
|
-
|
65
|
-
# Exchange the duo_code for a token with Duo to determine
|
66
|
-
# if the auth was successful.
|
77
|
+
# POST /oauth/v1/token
|
67
78
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
# duoCode -- Authentication session transaction id
|
72
|
-
# returned by Duo
|
73
|
-
# username -- Name of the user authenticating with Duo
|
79
|
+
# Arguments:
|
80
|
+
# duo_code -- Authentication session transaction id returned by Duo
|
81
|
+
# username -- Name of the user authenticating with Duo
|
74
82
|
|
75
|
-
|
76
|
-
|
83
|
+
# Return:
|
84
|
+
# A token with meta-data about the auth
|
77
85
|
|
78
|
-
|
79
|
-
|
80
|
-
|
86
|
+
# Raises:
|
87
|
+
# DuoException on error for invalid duo_codes, invalid credentials,
|
88
|
+
# or problems connecting to Duo
|
81
89
|
|
82
90
|
```
|
83
91
|
|
84
92
|
## Development
|
85
93
|
|
86
|
-
|
94
|
+
Run `bin/console` for an interactive prompt that will allow you to experiment.
|
87
95
|
|
88
96
|
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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
89
97
|
|
@@ -119,7 +119,7 @@ module DuoUniversalRuby
|
|
119
119
|
# if the auth was successful.
|
120
120
|
|
121
121
|
# Arguments:
|
122
|
-
#
|
122
|
+
# duo_code -- Authentication session transaction id
|
123
123
|
# returned by Duo
|
124
124
|
# username -- Name of the user authenticating with Duo
|
125
125
|
# nonce -- (Optional) Random 36B string used to associate
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: duo_universal_ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Todd Parsnick
|
@@ -15,14 +15,14 @@ dependencies:
|
|
15
15
|
requirements:
|
16
16
|
- - ">="
|
17
17
|
- !ruby/object:Gem::Version
|
18
|
-
version:
|
18
|
+
version: 2.2.2
|
19
19
|
type: :runtime
|
20
20
|
prerelease: false
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
22
22
|
requirements:
|
23
23
|
- - ">="
|
24
24
|
- !ruby/object:Gem::Version
|
25
|
-
version:
|
25
|
+
version: 2.2.2
|
26
26
|
description: Easily add two-factor authentication to any Ruby web authentication flow
|
27
27
|
using a Web SDKv4 app with the universal prompt in Duo.
|
28
28
|
email:
|
@@ -36,7 +36,6 @@ files:
|
|
36
36
|
- LICENSE.txt
|
37
37
|
- README.md
|
38
38
|
- Rakefile
|
39
|
-
- duo_universal_ruby.gemspec
|
40
39
|
- lib/duo_universal_ruby.rb
|
41
40
|
- lib/duo_universal_ruby/ca_certs.pem
|
42
41
|
- lib/duo_universal_ruby/client.rb
|
@@ -51,6 +50,7 @@ metadata:
|
|
51
50
|
homepage_uri: https://github.com/tparsnick/duo_universal_ruby
|
52
51
|
source_code_uri: https://github.com/tparsnick/duo_universal_ruby
|
53
52
|
changelog_uri: https://github.com/tparsnick/duo_universal_ruby/CHANGELOG.md
|
53
|
+
allowed_push_host: https://rubygems.org
|
54
54
|
rdoc_options: []
|
55
55
|
require_paths:
|
56
56
|
- lib
|
data/duo_universal_ruby.gemspec
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative "lib/duo_universal_ruby/version"
|
4
|
-
|
5
|
-
Gem::Specification.new do |spec|
|
6
|
-
spec.name = "duo_universal_ruby"
|
7
|
-
spec.version = DuoUniversalRuby::VERSION
|
8
|
-
spec.authors = ["Todd Parsnick"]
|
9
|
-
spec.email = ["tparsnick@gmail.com"]
|
10
|
-
|
11
|
-
spec.summary = "Easily add two-factor authentication to any Ruby web authentication flow using a Web SDKv4 app with the universal prompt in Duo."
|
12
|
-
spec.description = "Easily add two-factor authentication to any Ruby web authentication flow using a Web SDKv4 app with the universal prompt in Duo."
|
13
|
-
spec.homepage = 'https://github.com/tparsnick/duo_universal_ruby'
|
14
|
-
spec.license = "MIT"
|
15
|
-
spec.required_ruby_version = ">= 3.2.2"
|
16
|
-
|
17
|
-
# spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'"
|
18
|
-
|
19
|
-
spec.metadata["homepage_uri"] = spec.homepage
|
20
|
-
spec.metadata["source_code_uri"] = 'https://github.com/tparsnick/duo_universal_ruby'
|
21
|
-
spec.metadata["changelog_uri"] = 'https://github.com/tparsnick/duo_universal_ruby/CHANGELOG.md'
|
22
|
-
|
23
|
-
# Specify which files should be added to the gem when it is released.
|
24
|
-
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
25
|
-
spec.files = Dir.chdir(__dir__) do
|
26
|
-
`git ls-files -z`.split("\x0").reject do |f|
|
27
|
-
(File.expand_path(f) == __FILE__) ||
|
28
|
-
f.start_with?(*%w[bin/ test/ spec/ features/ .git .circleci appveyor Gemfile])
|
29
|
-
end
|
30
|
-
end
|
31
|
-
spec.bindir = "exe"
|
32
|
-
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
33
|
-
spec.require_paths = ["lib"]
|
34
|
-
|
35
|
-
# Runtime dependencies
|
36
|
-
spec.add_runtime_dependency 'jwt'
|
37
|
-
|
38
|
-
# For more information and examples about making a new gem, check out our
|
39
|
-
# guide at: https://bundler.io/guides/creating_gem.html
|
40
|
-
end
|