omniauth-swoop 0.1.3 → 0.1.4
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/.gitignore +59 -0
- data/README.md +20 -0
- data/lib/omniauth/strategies/swoop.rb +72 -0
- data/lib/omniauth/swoop-version.rb +5 -0
- data/omniauth-swoop.gemspec +18 -0
- metadata +28 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bd4aa8caa0678c66db380f845a96caf265efb87102a04e19d270f384842ea29d
|
4
|
+
data.tar.gz: c799f48f8ddf1aeb52dcb2d261dbc363aabb2f82e6b90fd011f8832404a8fe7f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 89035660cb20db74ce7bd15a6f410d00a907b54d60e685418680ac7a02a816773047cf1af0d9117abb51dfd356981e6ea2622a98bc1f87d8dc9dfdd0ba0ef67d
|
7
|
+
data.tar.gz: a8c0752357f8b552935b774f42ca5c61cf35a9d8eec18d950f0e2b591b2ec5571952bab3c52862be605ab171fe23b4d5c13258b8aa881c361970a814fdb98d40
|
data/.gitignore
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/spec/examples.txt
|
9
|
+
/test/tmp/
|
10
|
+
/test/version_tmp/
|
11
|
+
/tmp/
|
12
|
+
|
13
|
+
# Used by dotenv library to load environment variables.
|
14
|
+
# .env
|
15
|
+
|
16
|
+
# Ignore Byebug command history file.
|
17
|
+
.byebug_history
|
18
|
+
|
19
|
+
## Specific to RubyMotion:
|
20
|
+
.dat*
|
21
|
+
.repl_history
|
22
|
+
build/
|
23
|
+
*.bridgesupport
|
24
|
+
build-iPhoneOS/
|
25
|
+
build-iPhoneSimulator/
|
26
|
+
|
27
|
+
## Specific to RubyMotion (use of CocoaPods):
|
28
|
+
#
|
29
|
+
# We recommend against adding the Pods directory to your .gitignore. However
|
30
|
+
# you should judge for yourself, the pros and cons are mentioned at:
|
31
|
+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
32
|
+
#
|
33
|
+
# vendor/Pods/
|
34
|
+
|
35
|
+
## Documentation cache and generated files:
|
36
|
+
/.yardoc/
|
37
|
+
/_yardoc/
|
38
|
+
/doc/
|
39
|
+
/rdoc/
|
40
|
+
|
41
|
+
## Environment normalization:
|
42
|
+
/.bundle/
|
43
|
+
/vendor/bundle
|
44
|
+
/lib/bundler/man/
|
45
|
+
|
46
|
+
# for a library or gem, you might want to ignore these files since the code is
|
47
|
+
# intended to run in multiple environments; otherwise, check them in:
|
48
|
+
# Gemfile.lock
|
49
|
+
# .ruby-version
|
50
|
+
# .ruby-gemset
|
51
|
+
|
52
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
53
|
+
.rvmrc
|
54
|
+
|
55
|
+
# Used by RuboCop. Remote config files pulled in from inherit_from directive.
|
56
|
+
# .rubocop-https?--*
|
57
|
+
|
58
|
+
#personal notes
|
59
|
+
notes.md
|
data/README.md
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
## Description
|
2
|
+
Custom omniauth strategy for [Swoop](http://swoopnow.com), a password-free authentication tool.
|
3
|
+
|
4
|
+
## Rails Usage
|
5
|
+
Add `gem 'omniauth-swoop'` to your `Gemfile`
|
6
|
+
|
7
|
+
In `config/initializers/omniauth.rb` put the following code:
|
8
|
+
```
|
9
|
+
Rails.application.config.middleware.use OmniAuth::Builder do
|
10
|
+
provider :swoop, ENV['SWOOP_ID'], ENV['SWOOP_SECRET']
|
11
|
+
end
|
12
|
+
```
|
13
|
+
|
14
|
+
`ENV['SWOOP_ID']` should correspond to the `CLIENT_ID` of the `property` you set up via the swoop admin dashboard, and `ENV['SWOOP_SECRET']` should correspond to the property's `SECRET`.
|
15
|
+
|
16
|
+
## Testing
|
17
|
+
If you are contributing to this ruby gem you can test it by:
|
18
|
+
|
19
|
+
(1) running `gem build omniauth-swoop.gemspec` from the gem's root directory
|
20
|
+
(2) running `bundle update omniauth-swoop` in a test rails app.
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'omniauth-oauth2'
|
2
|
+
|
3
|
+
module OmniAuth
|
4
|
+
module Strategies
|
5
|
+
class Swoop < OmniAuth::Strategies::OAuth2
|
6
|
+
|
7
|
+
option :name, "swoop"
|
8
|
+
|
9
|
+
option :client_options, {
|
10
|
+
site: 'https://auth.swoop.email',
|
11
|
+
token_url: '/oauth2/token',
|
12
|
+
user_info_url: '/oauth2/profile'
|
13
|
+
}
|
14
|
+
|
15
|
+
option :user_response_structure, {
|
16
|
+
attributes: {
|
17
|
+
email: 'email',
|
18
|
+
uid: 'sub'
|
19
|
+
}
|
20
|
+
}
|
21
|
+
|
22
|
+
option :authorize_params, {
|
23
|
+
scope: 'email'
|
24
|
+
}
|
25
|
+
|
26
|
+
option :redirect_url
|
27
|
+
|
28
|
+
uid do
|
29
|
+
fetch_user_info(user_paths[:id_path]).to_s
|
30
|
+
end
|
31
|
+
|
32
|
+
info do
|
33
|
+
user_paths[:attributes].inject({}) do |user_hash, (field, path)|
|
34
|
+
value = fetch_user_info(path)
|
35
|
+
user_hash[field] = value if value
|
36
|
+
user_hash
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
extra do
|
41
|
+
{ raw_info: raw_info }
|
42
|
+
end
|
43
|
+
|
44
|
+
def raw_info
|
45
|
+
@raw_info ||= access_token.get(options.client_options[:user_info_url]).parsed
|
46
|
+
@raw_info["id_token"] = access_token.params["id_token"]
|
47
|
+
end
|
48
|
+
|
49
|
+
def authorize_params
|
50
|
+
params = super
|
51
|
+
Hash[params.map { |k, v| [k, v.respond_to?(:call) ? v.call(request) : v] }]
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def user_paths
|
57
|
+
options.user_response_structure
|
58
|
+
end
|
59
|
+
|
60
|
+
def fetch_user_info(path)
|
61
|
+
return nil unless path
|
62
|
+
full_path = path.is_a?(Array) ? path : Array(user_paths[:root_path]) + [path]
|
63
|
+
full_path.inject(raw_info) { |info, key| info[key] rescue nil }
|
64
|
+
end
|
65
|
+
|
66
|
+
def callback_url
|
67
|
+
options.redirect_url || (full_host + script_name + callback_path)
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
Gem::Specification.new do |s|
|
3
|
+
s.name = 'omniauth-swoop'
|
4
|
+
s.version = '0.1.4'
|
5
|
+
s.date = '2021-01-19'
|
6
|
+
s.homepage = "https://github.com/swoop-password-free/omniauth-swoop"
|
7
|
+
s.description = %q{OmniAuth strategy for Swoop passwordless authentication}
|
8
|
+
s.summary = s.description
|
9
|
+
s.authors = ["Brandon Trebitowski", "Charlie Wisoff"]
|
10
|
+
s.email = 'brandon@swoopnow.com'
|
11
|
+
s.files = `git ls-files`.split("\n")
|
12
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
13
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
14
|
+
s.require_paths = ["lib"]
|
15
|
+
s.required_ruby_version = Gem::Requirement.new('>= 1.9.3')
|
16
|
+
s.add_dependency 'omniauth-oauth2', '~> 1.7.1'
|
17
|
+
s.add_development_dependency 'bundler', '~> 1.0'
|
18
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniauth-swoop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandon Trebitowski
|
@@ -15,24 +15,43 @@ dependencies:
|
|
15
15
|
name: omniauth-oauth2
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- - "
|
18
|
+
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version:
|
20
|
+
version: 1.7.1
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- - "
|
25
|
+
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version:
|
28
|
-
|
27
|
+
version: 1.7.1
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: bundler
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '1.0'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '1.0'
|
42
|
+
description: OmniAuth strategy for Swoop passwordless authentication
|
29
43
|
email: brandon@swoopnow.com
|
30
44
|
executables: []
|
31
45
|
extensions: []
|
32
46
|
extra_rdoc_files: []
|
33
47
|
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- README.md
|
34
50
|
- lib/omniauth-swoop.rb
|
35
|
-
|
51
|
+
- lib/omniauth/strategies/swoop.rb
|
52
|
+
- lib/omniauth/swoop-version.rb
|
53
|
+
- omniauth-swoop.gemspec
|
54
|
+
homepage: https://github.com/swoop-password-free/omniauth-swoop
|
36
55
|
licenses: []
|
37
56
|
metadata: {}
|
38
57
|
post_install_message:
|
@@ -43,7 +62,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
43
62
|
requirements:
|
44
63
|
- - ">="
|
45
64
|
- !ruby/object:Gem::Version
|
46
|
-
version:
|
65
|
+
version: 1.9.3
|
47
66
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
48
67
|
requirements:
|
49
68
|
- - ">="
|
@@ -53,5 +72,5 @@ requirements: []
|
|
53
72
|
rubygems_version: 3.1.2
|
54
73
|
signing_key:
|
55
74
|
specification_version: 4
|
56
|
-
summary:
|
75
|
+
summary: OmniAuth strategy for Swoop passwordless authentication
|
57
76
|
test_files: []
|