omniauth-discord 1.0.0 → 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: 2eb69f9639617d5747654388e3fef787150c7ac82802f3c29c07889c2baa5c2b
4
- data.tar.gz: f9c7d75499726e2dfc28c6da5172492a326852015fc31521d2cff95a6d57141f
3
+ metadata.gz: 5a19b6c4bf2c6b7007749e7cffecb160e7da0b333c9a2be2607aeabeb1098453
4
+ data.tar.gz: 826c1db9c50b1d94ab02b973a6a4e642393a5bac5d44f6372bcafa739589a814
5
5
  SHA512:
6
- metadata.gz: 2e9da45436efa842917566fa28a91d75d13c49b346fe9e2f29d90b017ec45b64d8f0e90a1903648a0840a5ca238bbb24f7ab672eb47007b4873cae8e551e46f3
7
- data.tar.gz: ea0a1c97d9a7c7e8c43c40fd4de90af831829df2cd5b57addd706ee06431c6c51c878d07d09391eeec62023f47473269e1b57327dbc11e540356fc65493c78d9
6
+ metadata.gz: 845d18523d8844e0b8e85e2a6b102377dfc4a391a44c04c98978d74b0e28e27a6bf3e379d15a1cb54f3ccbda5977ee14617d6e8031e424b1710a98506bd379a6
7
+ data.tar.gz: 2f409257c5d20cdd4d275fa425981807139ecd7ed3bf902dde9de6a272244206b7d0ecbf9978d41344ce6db043159a5fdadf7797c005755f05f0db57798e1c9d
@@ -0,0 +1,33 @@
1
+ name: Ruby Gem
2
+
3
+ on:
4
+ release:
5
+ types:
6
+ - created
7
+
8
+ jobs:
9
+ build:
10
+
11
+ name: Build + Publish Gem
12
+ runs-on: ubuntu-latest
13
+ permissions:
14
+ contents: read
15
+ packages: write
16
+
17
+ steps:
18
+ - uses: actions/checkout@v2
19
+ - name: Set up Ruby
20
+ uses: ruby/setup-ruby@473e4d8fe5dd94ee328fdfca9f8c9c7afc9dae5e
21
+ with:
22
+ ruby-version: 2.7.2
23
+
24
+ - name: Publish to RubyGems
25
+ run: |
26
+ mkdir -p $HOME/.gem
27
+ touch $HOME/.gem/credentials
28
+ chmod 0600 $HOME/.gem/credentials
29
+ printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
30
+ gem build *.gemspec
31
+ gem push *.gem
32
+ env:
33
+ GEM_HOST_API_KEY: ${{secrets.RUBYGEMS_AUTH_TOKEN}}
@@ -0,0 +1,25 @@
1
+ name: Ruby
2
+
3
+ on:
4
+ push:
5
+ branches: [ master ]
6
+ pull_request:
7
+ branches: [ master ]
8
+
9
+ jobs:
10
+ test:
11
+
12
+ runs-on: ubuntu-latest
13
+ strategy:
14
+ matrix:
15
+ ruby-version: ['2.6', '2.7', '3.0', '3.1', '3.2']
16
+
17
+ steps:
18
+ - uses: actions/checkout@v2
19
+ - name: Set up Ruby
20
+ uses: ruby/setup-ruby@v1.131.0
21
+ with:
22
+ ruby-version: ${{ matrix.ruby-version }}
23
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
24
+ - name: Run tests
25
+ run: bundle exec rake
data/.travis.yml CHANGED
@@ -1,17 +1,28 @@
1
+ env:
2
+ global:
3
+ - CC_TEST_REPORTER_ID=ABC123
4
+
1
5
  language: ruby
2
6
  before_install: gem install bundler
3
7
 
4
8
  rvm:
9
+ - 2.6.1
5
10
  - 2.3.0
6
- - 2.2
7
- - 2.1
8
- - 2.0
9
11
  - jruby-head
10
- - rbx-2
11
-
12
+
12
13
  gemfile:
13
14
  - Gemfile
14
15
 
15
16
  notifications:
16
- email: false
17
+ email: true
18
+
19
+ before_script:
20
+ - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
21
+ - chmod +x ./cc-test-reporter
22
+ - ./cc-test-reporter before-build
23
+
24
+ script:
25
+ - bundle exec rspec
17
26
 
27
+ after_script:
28
+ - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
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,10 +41,18 @@ Rails.application.config.middleware.use OmniAuth::Builder do
47
41
  end
48
42
  ```
49
43
 
50
- ## Specifying additional permissions
44
+ You can also specify a callback URL by adding callback_url to the provider options.
45
+
46
+
47
+ ```ruby
48
+ Rails.application.config.middleware.use OmniAuth::Builder do
49
+ provider :discord, ENV['DISCORD_CLIENT_ID'], ENV['DISCORD_CLIENT_SECRET'], scope: 'email identify', callback_url: 'https://someurl.com/users/auth/discord/callback'
50
+ end
51
+ ```
52
+
53
+ ## Additional Permissions
51
54
 
52
- You can also request additional permissions from the user. See the
53
- [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.
54
56
 
55
57
  ```ruby
56
58
  Rails.application.config.middleware.use OmniAuth::Builder do
@@ -61,11 +63,15 @@ end
61
63
  This will request permission to the MANAGE_CHANNELS and the MANAGE_ROLES
62
64
  permissions.
63
65
 
66
+ ## Prompt Options
67
+
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.
69
+
64
70
  ## Contributing
65
71
 
66
- 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.
67
73
 
68
74
 
69
75
  ## License
70
76
 
71
- 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 ADDED
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'sinatra'
4
+ gem 'sinatra-reloader'
5
+ gem 'omniauth-discord', path: '../'
6
+ gem 'puma'
7
+ gem 'pry'
@@ -0,0 +1,77 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ omniauth-discord (1.1.0)
5
+ omniauth (~> 2.1.0)
6
+ omniauth-oauth2
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
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)
20
+ multi_xml (0.6.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)
26
+ jwt (>= 1.0, < 3.0)
27
+ multi_xml (~> 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)
45
+ rack
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)
51
+ tilt (~> 2.0)
52
+ sinatra-contrib (3.0.5)
53
+ multi_json
54
+ mustermann (~> 3.0)
55
+ rack-protection (= 3.0.5)
56
+ sinatra (= 3.0.5)
57
+ tilt (~> 2.0)
58
+ sinatra-reloader (1.0)
59
+ sinatra-contrib
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)
65
+
66
+ PLATFORMS
67
+ x86_64-linux
68
+
69
+ DEPENDENCIES
70
+ omniauth-discord!
71
+ pry
72
+ puma
73
+ sinatra
74
+ sinatra-reloader
75
+
76
+ BUNDLED WITH
77
+ 2.4.10
data/example/config.ru ADDED
@@ -0,0 +1,39 @@
1
+ require 'bundler/setup'
2
+ require 'omniauth'
3
+ require 'omniauth-discord'
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
12
+
13
+ use Rack::Session::Cookie, secret: '123456789'
14
+
15
+ use OmniAuth::Builder do
16
+ provider :discord, ENV['DISCORD_CLIENT_ID'], ENV['DISCORD_CLIENT_ID'], scope: ENV['SCOPE']
17
+ end
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
+
39
+ run Sinatra::Application
@@ -1,5 +1,5 @@
1
1
  module Omniauth
2
2
  module Discord
3
- VERSION = '1.0.0'.freeze
3
+ VERSION = '1.1.0'.freeze
4
4
  end
5
5
  end
@@ -8,11 +8,11 @@ module OmniAuth
8
8
  option :name, 'discord'
9
9
 
10
10
  option :client_options,
11
- site: 'https://discordapp.com/api',
11
+ site: 'https://discord.com/api',
12
12
  authorize_url: 'oauth2/authorize',
13
13
  token_url: 'oauth2/token'
14
14
 
15
- option :authorize_options, %i[scope permissions]
15
+ option :authorize_options, %i[scope permissions prompt]
16
16
 
17
17
  uid { raw_info['id'] }
18
18
 
@@ -20,13 +20,13 @@ module OmniAuth
20
20
  {
21
21
  name: raw_info['username'],
22
22
  email: raw_info['verified'] ? raw_info['email'] : nil,
23
- image: "https://cdn.discordapp.com/avatars/#{raw_info['id']}/#{raw_info['avatar']}"
23
+ image: raw_info['avatar'] ? "https://cdn.discordapp.com/avatars/#{raw_info['id']}/#{raw_info['avatar']}" : nil,
24
24
  }
25
25
  end
26
26
 
27
27
  extra do
28
28
  {
29
- 'raw_info' => raw_info
29
+ raw_info: raw_info
30
30
  }
31
31
  end
32
32
 
@@ -36,7 +36,7 @@ module OmniAuth
36
36
 
37
37
  def callback_url
38
38
  # Discord does not support query parameters
39
- full_host + script_name + callback_path
39
+ options[:redirect_uri] || (full_host + script_name + callback_path)
40
40
  end
41
41
 
42
42
  def authorize_params
@@ -17,10 +17,11 @@ 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'
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'
24
+ spec.add_development_dependency 'rake'
24
25
  spec.add_development_dependency 'rspec'
25
26
  spec.add_development_dependency 'simplecov'
26
27
  spec.add_development_dependency 'webmock'
metadata CHANGED
@@ -1,17 +1,31 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-discord
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
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: 2019-02-25 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
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 2.1.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 2.1.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: omniauth-oauth2
15
29
  requirement: !ruby/object:Gem::Requirement
16
30
  requirements:
17
31
  - - ">="
@@ -25,13 +39,13 @@ dependencies:
25
39
  - !ruby/object:Gem::Version
26
40
  version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
- name: omniauth-oauth2
42
+ name: rack-test
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
45
  - - ">="
32
46
  - !ruby/object:Gem::Version
33
47
  version: '0'
34
- type: :runtime
48
+ type: :development
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
@@ -39,7 +53,7 @@ dependencies:
39
53
  - !ruby/object:Gem::Version
40
54
  version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
- name: rack-test
56
+ name: rake
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
59
  - - ">="
@@ -101,6 +115,8 @@ executables: []
101
115
  extensions: []
102
116
  extra_rdoc_files: []
103
117
  files:
118
+ - ".github/workflows/gem-push.yml"
119
+ - ".github/workflows/rspec.yml"
104
120
  - ".gitignore"
105
121
  - ".rubocop.yml"
106
122
  - ".travis.yml"
@@ -108,6 +124,9 @@ files:
108
124
  - LICENSE.txt
109
125
  - README.md
110
126
  - Rakefile
127
+ - example/Gemfile
128
+ - example/Gemfile.lock
129
+ - example/config.ru
111
130
  - lib/omniauth-discord.rb
112
131
  - lib/omniauth/discord.rb
113
132
  - lib/omniauth/discord/version.rb
@@ -132,7 +151,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
132
151
  - !ruby/object:Gem::Version
133
152
  version: '0'
134
153
  requirements: []
135
- rubygems_version: 3.0.1
154
+ rubygems_version: 3.1.4
136
155
  signing_key:
137
156
  specification_version: 4
138
157
  summary: Discord OAuth2 Strategy for OmniAuth