omniauth-discord 1.0.2 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c7e8c36d444404a9248c61a4cbe2efc24ab9daedcc8d72b95371a64844c975eb
4
- data.tar.gz: 96619b3fd3c018843e8be931f8520fda07b2b30bfae2e843e587b5259f11f236
3
+ metadata.gz: 5a19b6c4bf2c6b7007749e7cffecb160e7da0b333c9a2be2607aeabeb1098453
4
+ data.tar.gz: 826c1db9c50b1d94ab02b973a6a4e642393a5bac5d44f6372bcafa739589a814
5
5
  SHA512:
6
- metadata.gz: a593ff764c850a8a4efb395e8bb8efe9cc56fe2e938aac169f782675dd89f80ff75882e0c5ac13fecf0870942371574df71da914cedf71608be80bbbcfc757cf
7
- data.tar.gz: 061d325e89a4a29e24b8bcdaf32c6a276f5d7e96da1cef5cb2ba87478ea2b93543b873c692c1d6535c4a996eae6aa2aa6ce3c7ba793b9ae616984f0be758c001
6
+ metadata.gz: 845d18523d8844e0b8e85e2a6b102377dfc4a391a44c04c98978d74b0e28e27a6bf3e379d15a1cb54f3ccbda5977ee14617d6e8031e424b1710a98506bd379a6
7
+ data.tar.gz: 2f409257c5d20cdd4d275fa425981807139ecd7ed3bf902dde9de6a272244206b7d0ecbf9978d41344ce6db043159a5fdadf7797c005755f05f0db57798e1c9d
@@ -12,12 +12,12 @@ jobs:
12
12
  runs-on: ubuntu-latest
13
13
  strategy:
14
14
  matrix:
15
- ruby-version: ['2.6', '2.7', '3.0']
15
+ ruby-version: ['2.6', '2.7', '3.0', '3.1', '3.2']
16
16
 
17
17
  steps:
18
18
  - uses: actions/checkout@v2
19
19
  - name: Set up Ruby
20
- uses: ruby/setup-ruby@473e4d8fe5dd94ee328fdfca9f8c9c7afc9dae5e
20
+ uses: ruby/setup-ruby@v1.131.0
21
21
  with:
22
22
  ruby-version: ${{ matrix.ruby-version }}
23
23
  bundler-cache: true # runs 'bundle install' and caches installed gems automatically
data/README.md CHANGED
@@ -1,24 +1,22 @@
1
1
  # OmniAuth Discord
2
2
 
3
- Discord OAuth2 Strategy for OmniAuth.
3
+ OmniAuth Discord - OAuth2 Strategy for OmniAuth
4
4
 
5
- Read the Discord API documentation for more details: https://discordapp.com/developers/docs/topics/oauth2
5
+ OmniAuth Discord is an OAuth2 strategy for OmniAuth that allows you to authenticate users using Discord. If you're not familiar with Discord's OAuth2, we recommend you check out the Discord API documentation for more details.
6
6
 
7
- ## Installing
7
+ ## Installation
8
8
 
9
- Add to your `Gemfile`:
9
+ To install OmniAuth Discord, simply add the following line to your Gemfile:
10
10
 
11
11
  ```ruby
12
12
  gem 'omniauth-discord'
13
13
  ```
14
14
 
15
- Then `bundle install`.
15
+ Then run bundle install to install the gem.
16
16
 
17
17
  ## Usage
18
18
 
19
- `OmniAuth::Strategies::Discord` is simply a Rack middleware. Read the OmniAuth docs for detailed instructions: https://github.com/intridea/omniauth.
20
-
21
- Here's a quick example, adding the middleware to a Rails app in `config/initializers/omniauth.rb`:
19
+ OmniAuth Discord is a Rack middleware. If you're not familiar with OmniAuth, we recommend reading the documentation for detailed instructions. Here's an example of how to add the middleware to a Rails app in config/initializers/omniauth.rb:
22
20
 
23
21
  ```ruby
24
22
  Rails.application.config.middleware.use OmniAuth::Builder do
@@ -26,10 +24,7 @@ Rails.application.config.middleware.use OmniAuth::Builder do
26
24
  end
27
25
  ```
28
26
 
29
- By default, Discord does not return a user's email address. Their API uses
30
- [scopes](https://discordapp.com/developers/docs/topics/oauth2#scopes) to provide
31
- access to certain resources of a user's account. For example, to get a user's
32
- email set the scope to `email`.
27
+ By default, Discord does not return a user's email address. You can request access to additional resources by setting scopes. For example, to get a user's email, you would set the scope to 'email'.
33
28
 
34
29
  ```ruby
35
30
  Rails.application.config.middleware.use OmniAuth::Builder do
@@ -37,8 +32,7 @@ Rails.application.config.middleware.use OmniAuth::Builder do
37
32
  end
38
33
  ```
39
34
 
40
- You can pass multiple scopes in the same string. For example to get a user's
41
- Discord account info set the scope to `email identify`
35
+ You can pass multiple scopes in the same string. For example, to get a user's Discord account info, you would set the scope to 'email identify'.
42
36
 
43
37
 
44
38
  ```ruby
@@ -47,7 +41,7 @@ Rails.application.config.middleware.use OmniAuth::Builder do
47
41
  end
48
42
  ```
49
43
 
50
- You can set callback url
44
+ You can also specify a callback URL by adding callback_url to the provider options.
51
45
 
52
46
 
53
47
  ```ruby
@@ -56,10 +50,9 @@ Rails.application.config.middleware.use OmniAuth::Builder do
56
50
  end
57
51
  ```
58
52
 
59
- ## Specifying additional permissions
53
+ ## Additional Permissions
60
54
 
61
- You can also request additional permissions from the user. See the
62
- [permission help page](https://discordapp.com/developers/docs/topics/permissions#bitwise-permission-flags) for a list of all available options.
55
+ You can request additional permissions from the user by setting the permissions option. For example, to request permission to the MANAGE_CHANNELS and MANAGE_ROLES permissions, you would set permissions to 0x00000010 + 0x10000000.
63
56
 
64
57
  ```ruby
65
58
  Rails.application.config.middleware.use OmniAuth::Builder do
@@ -70,15 +63,15 @@ end
70
63
  This will request permission to the MANAGE_CHANNELS and the MANAGE_ROLES
71
64
  permissions.
72
65
 
73
- ## Specifying the prompt options
66
+ ## Prompt Options
74
67
 
75
- Discord looks for the prompt option to indicate if the user should be prompted to reauthorize on sign in. Valid options are 'consent' and 'none'. Note that the use is always prompted to authorize on sign up.
68
+ You can specify the prompt options by setting the prompt option. The prompt option indicates whether the user should be prompted to reauthorize on sign in. Valid options are 'consent' and 'none'. Note that the user is always prompted to authorize on sign up.
76
69
 
77
70
  ## Contributing
78
71
 
79
- Bug reports and pull requests are welcome on GitHub at https://github.com/adaoraul/omniauth-discord.
72
+ If you find a bug or want to contribute to the project, we welcome bug reports and pull requests on GitHub.
80
73
 
81
74
 
82
75
  ## License
83
76
 
84
- The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
77
+ OmniAuth Discord is available as open-source software under the [MIT License](http://opensource.org/licenses/MIT).
data/example/Gemfile CHANGED
@@ -3,3 +3,5 @@ source 'https://rubygems.org'
3
3
  gem 'sinatra'
4
4
  gem 'sinatra-reloader'
5
5
  gem 'omniauth-discord', path: '../'
6
+ gem 'puma'
7
+ gem 'pry'
data/example/Gemfile.lock CHANGED
@@ -1,60 +1,77 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- omniauth-discord (1.0.0)
5
- omniauth
4
+ omniauth-discord (1.1.0)
5
+ omniauth (~> 2.1.0)
6
6
  omniauth-oauth2
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- backports (3.15.0)
12
- faraday (0.15.4)
13
- multipart-post (>= 1.2, < 3)
14
- hashie (3.6.0)
15
- jwt (2.2.1)
16
- multi_json (1.13.1)
11
+ coderay (1.1.3)
12
+ faraday (2.7.4)
13
+ faraday-net_http (>= 2.0, < 3.1)
14
+ ruby2_keywords (>= 0.0.4)
15
+ faraday-net_http (3.0.2)
16
+ hashie (5.0.0)
17
+ jwt (2.7.0)
18
+ method_source (1.0.0)
19
+ multi_json (1.15.0)
17
20
  multi_xml (0.6.0)
18
- multipart-post (2.1.1)
19
- mustermann (1.0.3)
20
- oauth2 (1.4.1)
21
- faraday (>= 0.8, < 0.16.0)
21
+ mustermann (3.0.0)
22
+ ruby2_keywords (~> 0.0.1)
23
+ nio4r (2.5.9)
24
+ oauth2 (2.0.9)
25
+ faraday (>= 0.17.3, < 3.0)
22
26
  jwt (>= 1.0, < 3.0)
23
- multi_json (~> 1.3)
24
27
  multi_xml (~> 0.5)
25
- rack (>= 1.2, < 3)
26
- omniauth (1.9.0)
27
- hashie (>= 3.4.6, < 3.7.0)
28
- rack (>= 1.6.2, < 3)
29
- omniauth-oauth2 (1.6.0)
30
- oauth2 (~> 1.1)
31
- omniauth (~> 1.9)
32
- rack (2.2.3)
33
- rack-protection (2.0.5)
28
+ rack (>= 1.2, < 4)
29
+ snaky_hash (~> 2.0)
30
+ version_gem (~> 1.1)
31
+ omniauth (2.1.1)
32
+ hashie (>= 3.4.6)
33
+ rack (>= 2.2.3)
34
+ rack-protection
35
+ omniauth-oauth2 (1.8.0)
36
+ oauth2 (>= 1.4, < 3)
37
+ omniauth (~> 2.0)
38
+ pry (0.14.2)
39
+ coderay (~> 1.1)
40
+ method_source (~> 1.0)
41
+ puma (6.2.1)
42
+ nio4r (~> 2.0)
43
+ rack (2.2.6.4)
44
+ rack-protection (3.0.5)
34
45
  rack
35
- sinatra (2.0.5)
36
- mustermann (~> 1.0)
37
- rack (~> 2.0)
38
- rack-protection (= 2.0.5)
46
+ ruby2_keywords (0.0.5)
47
+ sinatra (3.0.5)
48
+ mustermann (~> 3.0)
49
+ rack (~> 2.2, >= 2.2.4)
50
+ rack-protection (= 3.0.5)
39
51
  tilt (~> 2.0)
40
- sinatra-contrib (2.0.5)
41
- backports (>= 2.8.2)
52
+ sinatra-contrib (3.0.5)
42
53
  multi_json
43
- mustermann (~> 1.0)
44
- rack-protection (= 2.0.5)
45
- sinatra (= 2.0.5)
46
- tilt (>= 1.3, < 3)
54
+ mustermann (~> 3.0)
55
+ rack-protection (= 3.0.5)
56
+ sinatra (= 3.0.5)
57
+ tilt (~> 2.0)
47
58
  sinatra-reloader (1.0)
48
59
  sinatra-contrib
49
- tilt (2.0.9)
60
+ snaky_hash (2.0.1)
61
+ hashie
62
+ version_gem (~> 1.1, >= 1.1.1)
63
+ tilt (2.1.0)
64
+ version_gem (1.1.2)
50
65
 
51
66
  PLATFORMS
52
- ruby
67
+ x86_64-linux
53
68
 
54
69
  DEPENDENCIES
55
70
  omniauth-discord!
71
+ pry
72
+ puma
56
73
  sinatra
57
74
  sinatra-reloader
58
75
 
59
76
  BUNDLED WITH
60
- 2.0.2
77
+ 2.4.10
data/example/config.ru CHANGED
@@ -1,6 +1,14 @@
1
1
  require 'bundler/setup'
2
+ require 'omniauth'
2
3
  require 'omniauth-discord'
3
- require './app.rb'
4
+ require 'sinatra'
5
+ require "sinatra/reloader"
6
+
7
+ configure do
8
+ set :sessions, true
9
+ set :run, false
10
+ set :raise_errors, true
11
+ end
4
12
 
5
13
  use Rack::Session::Cookie, secret: '123456789'
6
14
 
@@ -8,4 +16,24 @@ use OmniAuth::Builder do
8
16
  provider :discord, ENV['DISCORD_CLIENT_ID'], ENV['DISCORD_CLIENT_ID'], scope: ENV['SCOPE']
9
17
  end
10
18
 
19
+ get '/' do
20
+ content_type 'text/html'
21
+ <<-HTML
22
+ <html>
23
+ <body>
24
+ <form method='post' action='/auth/discord'>
25
+ <input type="hidden" name="authenticity_token" value='#{request.env["rack.session"]["csrf"]}'>
26
+ <button type='submit'>Login with Discord</button>
27
+ </form>
28
+ </body>
29
+ </html>
30
+ HTML
31
+ end
32
+
33
+ get '/auth/:provider/callback' do
34
+ content_type 'application/json'
35
+ request.env['omniauth.auth'].to_json
36
+ end
37
+
38
+
11
39
  run Sinatra::Application
@@ -1,5 +1,5 @@
1
1
  module Omniauth
2
2
  module Discord
3
- VERSION = '1.0.2'.freeze
3
+ VERSION = '1.1.0'.freeze
4
4
  end
5
5
  end
@@ -20,14 +20,13 @@ module OmniAuth
20
20
  {
21
21
  name: raw_info['username'],
22
22
  email: raw_info['verified'] ? raw_info['email'] : nil,
23
- # CDN is still cdn.discordapp.com
24
- image: raw_info['avatar'].present? ? "https://cdn.discordapp.com/avatars/#{raw_info['id']}/#{raw_info['avatar']}" : nil,
23
+ image: raw_info['avatar'] ? "https://cdn.discordapp.com/avatars/#{raw_info['id']}/#{raw_info['avatar']}" : nil,
25
24
  }
26
25
  end
27
26
 
28
27
  extra do
29
28
  {
30
- 'raw_info' => raw_info
29
+ raw_info: raw_info
31
30
  }
32
31
  end
33
32
 
@@ -37,7 +36,7 @@ module OmniAuth
37
36
 
38
37
  def callback_url
39
38
  # Discord does not support query parameters
40
- options[:callback_url] || (full_host + script_name + callback_path)
39
+ options[:redirect_uri] || (full_host + script_name + callback_path)
41
40
  end
42
41
 
43
42
  def authorize_params
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
17
17
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
18
  spec.require_paths = ['lib']
19
19
 
20
- spec.add_runtime_dependency 'omniauth', '~> 2.0.4'
20
+ spec.add_runtime_dependency 'omniauth', '~> 2.1.0'
21
21
  spec.add_runtime_dependency 'omniauth-oauth2'
22
22
 
23
23
  spec.add_development_dependency 'rack-test'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-discord
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adão Raul
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-15 00:00:00.000000000 Z
11
+ date: 2023-04-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: omniauth
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 2.0.4
19
+ version: 2.1.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 2.0.4
26
+ version: 2.1.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: omniauth-oauth2
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -126,7 +126,6 @@ files:
126
126
  - Rakefile
127
127
  - example/Gemfile
128
128
  - example/Gemfile.lock
129
- - example/app.rb
130
129
  - example/config.ru
131
130
  - lib/omniauth-discord.rb
132
131
  - lib/omniauth/discord.rb
data/example/app.rb DELETED
@@ -1,23 +0,0 @@
1
- require 'sinatra'
2
- require "sinatra/reloader"
3
- require 'yaml'
4
-
5
- # configure sinatra
6
- set :run, false
7
- set :raise_errors, true
8
-
9
- get '/' do
10
- content_type 'text/html'
11
- <<-HTML
12
- <html>
13
- <body>
14
- <a href="/auth/discord">Connect to Discord!</a>
15
- </body>
16
- </html>
17
- HTML
18
- end
19
-
20
- get '/auth/:provider/callback' do
21
- content_type 'application/json'
22
- MultiJson.encode(request.env)
23
- end