omniauth-humanid 0.0.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +19 -0
- data/LICENSE.txt +21 -0
- data/README.md +152 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/bin/update +33 -0
- data/changelog.md +1 -0
- data/lib/omniauth-humanid.rb +99 -0
- data/omniauth-humanid.gemspec +32 -0
- metadata +62 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 32a28f75ea3b1c0cc7c2feb636f7bfa2df28328f1f327e84bfb00d5782f52bc3
|
4
|
+
data.tar.gz: ff1b440841f70b10667b2d675a11f58196998f277a3d829bfe419b4d74918876
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 95eb05f588a3d876740c16bc96dd834b04ff4e669c723a236fe82f25f7ab07f89ff1d152bd6dbcfef8d2bd6b143267ab21dce836ebab41303ccd127bfafcd441
|
7
|
+
data.tar.gz: 3a74040881260644db1df2f758b04110147eb4482a565632fa73d36a51ae411272495917f1f8c3014821f88c694cf0c5776ee2a308035c4a99a3555a13eaf554
|
data/.gitignore
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team over github, twitter, or email. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [https://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: https://contributor-covenant.org
|
74
|
+
[version]: https://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2022 TODO: Write your name
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,152 @@
|
|
1
|
+
# Ruby/Rails OmniAuth for HumanID Alpha
|
2
|
+
|
3
|
+
Omniauth for humanID, a platform that prevents bots and increases privacy. HumanID is run by Human Internet,
|
4
|
+
a non-profit that is currently financed by organizations such as Harvard and the Mozilla Foundation (I love the Mozilla
|
5
|
+
Developer Network (MDN) which gives great javascript information).
|
6
|
+
|
7
|
+
HumanID works best when used as the only sign-up solution, due to this HumanID has to be highly trusted. This is where their
|
8
|
+
non-profit status steps in. HumanID has many benifits:
|
9
|
+
|
10
|
+
1. Increased privacy for users through both technical innovations and legal responsibilities.
|
11
|
+
2. Making bots inconvienient by requiring phone verification.
|
12
|
+
3. 'One voice one vote' type benefits by making it difficult to have multiple accounts.
|
13
|
+
4. Dont have to deal with users putting in "password123" as a password.
|
14
|
+
5. Dont have to deal with email/password registration generally (my signup process became way less complicated, there was all this stuff which to be honest I just didn't really get).
|
15
|
+
6. Much better look than "sign up with [tech monopoly here]" buttons.
|
16
|
+
|
17
|
+
## Installation
|
18
|
+
|
19
|
+
Add this line to your application's Gemfile:
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
gem 'omniauth-humanid'
|
23
|
+
```
|
24
|
+
|
25
|
+
And then execute:
|
26
|
+
|
27
|
+
$ bundle install
|
28
|
+
|
29
|
+
Or install it yourself as:
|
30
|
+
|
31
|
+
$ gem install omniauth-humanid
|
32
|
+
|
33
|
+
Update as normal.
|
34
|
+
|
35
|
+
## Configuration
|
36
|
+
|
37
|
+
1. Make an account at humanID, and get appropriate credentials
|
38
|
+
2. You will need to set credentials for client-id and client-secret, for both development and production. This can be done using the rails:credentials method or Enviroment Variables. These both have various advantage/disadvantages.
|
39
|
+
3. do some configuration in your initializers, for devise the steps are:
|
40
|
+
- open config/initializers/devise.rb
|
41
|
+
- enter the below code within the "Devise.setup" area
|
42
|
+
```ruby
|
43
|
+
Devise.setup do |config|
|
44
|
+
id = Rails.application.credentials.omniauth_humanid_client_id
|
45
|
+
secret = Rails.application.credentials.omniauth_humanid_client_secret
|
46
|
+
config.omniauth :humanid, client_secret: secret, client_id: id
|
47
|
+
end
|
48
|
+
```
|
49
|
+
4. Make your signup button
|
50
|
+
- I use html which is a bit diffrent than what was provided to allow for CSRF concerns raised in [this gem](https://github.com/cookpad/omniauth-rails_csrf_protection). To follow these instructions, first install and setup that gem
|
51
|
+
- Next your going to want to put this button code in a partial since you will be using it semi-regularly in your code base (convert to irb if needed):
|
52
|
+
```ruby
|
53
|
+
.btn.common-sign-up-with-btn
|
54
|
+
= form_with url: user_humanid_omniauth_authorize_path, method: :post do
|
55
|
+
%input{type: :image, src: image_pack_path("icons/sign_in_logos/humanID.svg"), alt: "Anonymous Login with humanID"}
|
56
|
+
```
|
57
|
+
5. Create your callback area (still in development)
|
58
|
+
- This area is generally supposed to be customizable, as you might have a diffrent model name, want to attach some validations, etc, etc. So it is not included in the gem, but is here as a how-to.
|
59
|
+
- TBD
|
60
|
+
|
61
|
+
## Additional configuration
|
62
|
+
|
63
|
+
### Omniauth options
|
64
|
+
|
65
|
+
additional configuration can be set in your initializer file at the same area and in the same method as your client-secret and client-id. Additional configuration is as follows:
|
66
|
+
- lang: default language code. Defaults to 'en' (english). Set to nil to remove from url.
|
67
|
+
- humanid_version: version string that goes in the url. Defaults to 'v0.0.3'. If humanid updates this may need to be updated aswell.
|
68
|
+
- priority_country: not sure exactly what this does or how to use it, but it was in the docs so i added it as an option. Defaults to nil.
|
69
|
+
- external_signup_url: the web login url. Defaults to: "https://core.human-id.org/[HUMANID_VERSION]/server/users/web-login". [HUMANID_VERSION] gets substituted by humanid_version above.
|
70
|
+
|
71
|
+
### Devise without emails/passwords
|
72
|
+
|
73
|
+
Once again, humanID is better when used alone bue to bot mitigation. This section is how to remove email/password authentication.
|
74
|
+
|
75
|
+
Although Devise is easier to deal with without usernames / passwords, it takes a bit to get there. This is out of the gem scope, but here are some pointers below. You may run into other hurdles depending on your setup.
|
76
|
+
1. In your user.rb (or similar) model, in your devise config line, remove all of the following:
|
77
|
+
- confirmable
|
78
|
+
- database_authenticatable
|
79
|
+
- recoverable
|
80
|
+
- confirmable
|
81
|
+
- lockable
|
82
|
+
2. In your devise.rb initializer file, make sure to set authentication_keys to []
|
83
|
+
3. delete or comment out the selections in devise.rb related to number 1.
|
84
|
+
4. I had to add back the route below:
|
85
|
+
```ruby
|
86
|
+
as :user do
|
87
|
+
delete "/users/sign_out" => "users/sessions#destroy"
|
88
|
+
end
|
89
|
+
```
|
90
|
+
5. For development you may have to create a seperate way to login/signup for testing purposes. You can do this by sending a form that implements the method 'sign_in_and_redirect user, event: :authentication', or that sets fake values for signup. MAKE SURE THIS METHOD IS ONLY ACTIVE DURING DEVELOPMENT. I have a version of this below:
|
91
|
+
- in my routes.rb:
|
92
|
+
```ruby
|
93
|
+
as :user do
|
94
|
+
if Rails.env.development?
|
95
|
+
post '/users/override' => 'users/omniauth_callbacks#callback_override'
|
96
|
+
end
|
97
|
+
end
|
98
|
+
```
|
99
|
+
- in my OmniauthCallbacksController override (see devise documentation):
|
100
|
+
```ruby
|
101
|
+
def callback_common(provider, uid)
|
102
|
+
user = User.from_omniauth(provider, uid)
|
103
|
+
if user
|
104
|
+
#allready have an account, sign them in
|
105
|
+
sign_in_and_redirect user, event: :authentication # this will throw if user is not activated
|
106
|
+
else
|
107
|
+
request.session['signup'] ||= {}
|
108
|
+
request.session["signup"]["provider"] = provider
|
109
|
+
request.session["signup"]["uid"] = uid
|
110
|
+
raise StandardError.new("REPLACE THIS ERROR WITH A REDIRECT TO FINISH SIGNUP")
|
111
|
+
end
|
112
|
+
end
|
113
|
+
if Rails.env.development?
|
114
|
+
def callback_override
|
115
|
+
raise StandardError.new("nope") unless Rails.env.development?
|
116
|
+
provider = 'override'
|
117
|
+
uid = params['uid']
|
118
|
+
callback_common provider, uid
|
119
|
+
end
|
120
|
+
end
|
121
|
+
```
|
122
|
+
- my form (hidden in a dropdown menu)
|
123
|
+
```ruby
|
124
|
+
- if Rails.env.development?
|
125
|
+
.dropdown-item
|
126
|
+
= form_with url: users_override_path, method: :post do
|
127
|
+
%p put username below to bypass the humanID in development
|
128
|
+
= text_field_tag :uid, '', class: 'form-control'
|
129
|
+
= submit_tag "GO", class: "btn btn-primary"
|
130
|
+
```
|
131
|
+
|
132
|
+
## Development of the Gem (Gem usage info stops here)
|
133
|
+
|
134
|
+
After checking out the repo, run `bin/setup` to install dependencies.
|
135
|
+
|
136
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in the gemspec file, 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).
|
137
|
+
|
138
|
+
When developing the Gem, for minor updates while debugging etc, we have a custom script to update the gem
|
139
|
+
- in the root folder of the gem run ./bin/update. This will bump the version number by one in the gemspec, commit all changes with a generic message, and then install this minor version on your machine.
|
140
|
+
- For more information see the ./bin/update file.
|
141
|
+
|
142
|
+
## Contributing
|
143
|
+
|
144
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/LukeClancy/omniauth-humanid. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/LukeClancy/omniauth-humanid/blob/master/CODE_OF_CONDUCT.md).
|
145
|
+
|
146
|
+
## License
|
147
|
+
|
148
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
149
|
+
|
150
|
+
## Code of Conduct
|
151
|
+
|
152
|
+
Everyone interacting in the Omniauth::Humanid project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/LukeClancy/omniauth-humanid/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "omniauth/humanid"
|
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(__FILE__)
|
data/bin/setup
ADDED
data/bin/update
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
#!/bin/env ruby
|
2
|
+
#this is for local development and should not be for actual updates,
|
3
|
+
# I just got annoyed with the number of things you had to do to get the updated
|
4
|
+
# version on your machine. Even after this you have to update the and restart your website...
|
5
|
+
# you can one-line that with './bin/bundle update && ../bin rails s' though. Just
|
6
|
+
# make sure you use ~> in the gemfile and your first 2 version numbers are correct.
|
7
|
+
|
8
|
+
x = File.read('./omniauth-humanid.gemspec')
|
9
|
+
x = x.split("\n")
|
10
|
+
puts x.class
|
11
|
+
puts x.length
|
12
|
+
puts x
|
13
|
+
puts "_______________________________________________"
|
14
|
+
version = eval(x[0])
|
15
|
+
puts "version: #{version}"
|
16
|
+
puts "_______________________________________________"
|
17
|
+
version = version.split('.')
|
18
|
+
version[-1] = ((version[-1].to_i) + 1).to_s
|
19
|
+
version_new = version.join('.')
|
20
|
+
puts "version_new: #{version_new}"
|
21
|
+
puts "_______________________________________________"
|
22
|
+
x[0] = "version = '#{version_new}'"
|
23
|
+
puts "x[0] => #{x[0]}"
|
24
|
+
puts "_______________________________________________"
|
25
|
+
x = x.join("\n")
|
26
|
+
puts x
|
27
|
+
File.write('./omniauth-humanid.gemspec', x)
|
28
|
+
puts "_______________________________________________"
|
29
|
+
puts `git add *`
|
30
|
+
puts "_______________________________________________"
|
31
|
+
puts `git commit -m 'minor changes to version #{version_new}'`
|
32
|
+
puts "_______________________________________________"
|
33
|
+
puts `bundle exec rake install`
|
data/changelog.md
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
## This page will have proper updates when it is functional enough to warrent that
|
@@ -0,0 +1,99 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
module OmniAuth
|
4
|
+
module Strategies
|
5
|
+
class Humanid
|
6
|
+
include OmniAuth::Strategy
|
7
|
+
#Omniauth strategy creation guide be useful
|
8
|
+
#https://github.com/omniauth/omniauth/wiki/Strategy-Contribution-Guide
|
9
|
+
|
10
|
+
#then this guy created another useful blog 🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥
|
11
|
+
#🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥
|
12
|
+
#https://dev.to/vvo/devise-create-a-local-omniauth-strategy-for-slack-4066
|
13
|
+
|
14
|
+
#note the image in the below documentation, I will try to reference back to it below
|
15
|
+
#https://docs.human-id.org/web-sdk-integration-guide#api-request-web-log-in-session
|
16
|
+
|
17
|
+
#options :login_button_path, '[LOGIN_BUTTON_PATH]'
|
18
|
+
option :humanid_version, 'v0.0.3'
|
19
|
+
#options :local_sign_up_url, "/auth/humanid"
|
20
|
+
option :external_signup_url, "https://core.human-id.org/[HUMANID_VERSION]/server/users/web-login"
|
21
|
+
option :lang, :en
|
22
|
+
option :priority_country, nil #this is an option in the docs, but they dont give an example value (otherwise I would set to united_states, or us, or 1)
|
23
|
+
option :client_secret, nil
|
24
|
+
option :client_id, nil
|
25
|
+
|
26
|
+
# def self.humanid_button
|
27
|
+
# #see https://docs.human-id.org/web-sdk-integration-guide
|
28
|
+
# %Q{<a href="#{options.local_sign_up_url}">
|
29
|
+
# <img src="#{options.login_button_path}" alt="Anonymous Login with humanID" height="27"/>
|
30
|
+
# <a>}
|
31
|
+
# end
|
32
|
+
|
33
|
+
def get_client_id
|
34
|
+
#basic check for client_id
|
35
|
+
return options.client_id unless options.client_id.nil?
|
36
|
+
raise StandardError.new("Please set omniauth-humanid client id")
|
37
|
+
end
|
38
|
+
def get_client_secret
|
39
|
+
#basic check for client_secret
|
40
|
+
return options.client_secret unless options.client_secret.nil?
|
41
|
+
raise StandardError.new("Set omniauth-humanid client secret")
|
42
|
+
end
|
43
|
+
def get_external_signup_uri
|
44
|
+
uri = URI(options.external_signup_url.gsub('[HUMANID_VERSION]', options.humanid_version))
|
45
|
+
query = [
|
46
|
+
['lang', options.lang],
|
47
|
+
['priority_country', options.priority_country]
|
48
|
+
].select{|a| not a[1].nil?}
|
49
|
+
uri.query = URI.encode_www_form(query)
|
50
|
+
return uri
|
51
|
+
end
|
52
|
+
def request_phase_err(res)
|
53
|
+
raise StandardError.new("Issue with the request phase of humanid omniauth, response from human id has code: #{res.code}, and body: #{res.body}")
|
54
|
+
end
|
55
|
+
#request phase
|
56
|
+
def request_phase
|
57
|
+
# In the humanid web-sdk-integration-guide, this would be the "[1] login" step. We need to get the redirect url
|
58
|
+
# through a post request, and then send that to the user.
|
59
|
+
|
60
|
+
#see more on Net::HTTP here:
|
61
|
+
# https://ruby-doc.org/stdlib-2.4.1/libdoc/net/http/rdoc/Net/HTTP.html
|
62
|
+
|
63
|
+
#get uri
|
64
|
+
uri = get_external_signup_uri
|
65
|
+
Rails.logger.debug "HUMANID_OMNIAUTH URI: #{uri.to_s}"
|
66
|
+
#make a post request (but dont send it yet)
|
67
|
+
post_request = Net::HTTP::Post.new(uri)
|
68
|
+
#set the headers as per docs.
|
69
|
+
post_request['client-id'] = get_client_id
|
70
|
+
post_request['client-secret'] = get_client_secret
|
71
|
+
post_request['Content-Type'] = 'application/json'
|
72
|
+
#send the request using a weirdly 🤷♂️ overcomplicated 🤷♂️ method 🤷♂️ and 🤷♂️ block 🤷♂️ blame Net::HTTP
|
73
|
+
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true){|http| http.request(post_request)}
|
74
|
+
Rails.logger.info(res)
|
75
|
+
if res.code == "200"
|
76
|
+
body = JSON.parse(res.body)
|
77
|
+
# they have five diffrent metrics for success:
|
78
|
+
# 1. the response code 200
|
79
|
+
# 2. body["success"] == true
|
80
|
+
# 3. body["code"] == "OK"
|
81
|
+
# 4. body["message"] == "success"
|
82
|
+
# 5. body["data"]["webLoginUrl"] is actually there
|
83
|
+
# I check 1 and 5 since the others seem supplimentary
|
84
|
+
|
85
|
+
#get the redirect url
|
86
|
+
Rails.logger.info(body)
|
87
|
+
redirect_url = body.dig("data", "webLoginUrl")
|
88
|
+
#check it, throw an error if nil or an int or something random.
|
89
|
+
request_phase_err(res) unless redirect_url.kind_of? String
|
90
|
+
#redirect (everything is working!)
|
91
|
+
Rails.logger.info(redirect_url)
|
92
|
+
redirect redirect_url
|
93
|
+
else
|
94
|
+
request_phase_err(res)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
version = '0.0.15'
|
2
|
+
#version must be on the first line for the update script
|
3
|
+
|
4
|
+
Gem::Specification.new do |spec|
|
5
|
+
spec.name = "omniauth-humanid"
|
6
|
+
spec.version = version
|
7
|
+
spec.authors = ["Luke Clancy"]
|
8
|
+
spec.email = ["lukeclancy@hotmail.com"]
|
9
|
+
|
10
|
+
spec.summary = %q{omniauth-humanid is an omniauth strategy for humanID, a company that provides bot-adverse and private signup functionality. Tested with the devise and omniauth gem}
|
11
|
+
spec.homepage = "https://github.com/LukeClancy/omniauth-humanid/blob/master/README.md"
|
12
|
+
spec.license = "MIT"
|
13
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
14
|
+
|
15
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
16
|
+
|
17
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
18
|
+
spec.metadata["source_code_uri"] = "https://github.com/LukeClancy/omniauth-humanid"
|
19
|
+
spec.metadata["changelog_uri"] = "https://github.com/LukeClancy/omniauth-humanid/blob/master/changelog.md"
|
20
|
+
|
21
|
+
# Specify which files should be added to the gem when it is released.
|
22
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
23
|
+
|
24
|
+
#Note: is this magic?
|
25
|
+
|
26
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
27
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
28
|
+
end
|
29
|
+
spec.bindir = "exe"
|
30
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
31
|
+
spec.require_paths = ["lib"]
|
32
|
+
end
|
metadata
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-humanid
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.15
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Luke Clancy
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-08-22 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description:
|
14
|
+
email:
|
15
|
+
- lukeclancy@hotmail.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- ".gitignore"
|
21
|
+
- CODE_OF_CONDUCT.md
|
22
|
+
- Gemfile
|
23
|
+
- Gemfile.lock
|
24
|
+
- LICENSE.txt
|
25
|
+
- README.md
|
26
|
+
- Rakefile
|
27
|
+
- bin/console
|
28
|
+
- bin/setup
|
29
|
+
- bin/update
|
30
|
+
- changelog.md
|
31
|
+
- lib/omniauth-humanid.rb
|
32
|
+
- omniauth-humanid.gemspec
|
33
|
+
homepage: https://github.com/LukeClancy/omniauth-humanid/blob/master/README.md
|
34
|
+
licenses:
|
35
|
+
- MIT
|
36
|
+
metadata:
|
37
|
+
allowed_push_host: https://rubygems.org
|
38
|
+
homepage_uri: https://github.com/LukeClancy/omniauth-humanid/blob/master/README.md
|
39
|
+
source_code_uri: https://github.com/LukeClancy/omniauth-humanid
|
40
|
+
changelog_uri: https://github.com/LukeClancy/omniauth-humanid/blob/master/changelog.md
|
41
|
+
post_install_message:
|
42
|
+
rdoc_options: []
|
43
|
+
require_paths:
|
44
|
+
- lib
|
45
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: 2.3.0
|
50
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
requirements: []
|
56
|
+
rubygems_version: 3.1.6
|
57
|
+
signing_key:
|
58
|
+
specification_version: 4
|
59
|
+
summary: omniauth-humanid is an omniauth strategy for humanID, a company that provides
|
60
|
+
bot-adverse and private signup functionality. Tested with the devise and omniauth
|
61
|
+
gem
|
62
|
+
test_files: []
|