omniauth-roblox 0.0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 0bf2f52cc783b6a23260c21901b9404ea3efc4564b3a8f8331a299501ff0c7c1
4
+ data.tar.gz: b51116d747e5362dcbacd427c3ac0b7097b07bd0d6868c0ee5fe5e8fb3796e1c
5
+ SHA512:
6
+ metadata.gz: f82761ea7895efc0cfaee69e4996446749d05a4e72a2140478ab5f10005566912ea04455a5f717a0ace28aec35d62afe64b8a8d5bd932aefebb9600f37c4a630
7
+ data.tar.gz: 3b5bb51b61a4828433cdd5d7b1c30ea4d33858773486fede900c326aa4656d82b86d04d6aea27c707206e4d6d8014cf2d709dad2e73e435a4b77cc6a2aa2cfb2
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gemspec
6
+
7
+ gem 'rake', group: 'development'
8
+ gem 'rubocop', '~> 1.36', group: 'development'
data/Gemfile.lock ADDED
@@ -0,0 +1,74 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ omniauth-roblox (0.0.1)
5
+ jwt (~> 2.5)
6
+ omniauth (~> 2.1)
7
+ omniauth-oauth2 (~> 1.8)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ ast (2.4.2)
13
+ faraday (2.5.2)
14
+ faraday-net_http (>= 2.0, < 3.1)
15
+ ruby2_keywords (>= 0.0.4)
16
+ faraday-net_http (3.0.0)
17
+ hashie (5.0.0)
18
+ json (2.6.2)
19
+ jwt (2.5.0)
20
+ multi_xml (0.6.0)
21
+ oauth2 (2.0.8)
22
+ faraday (>= 0.17.3, < 3.0)
23
+ jwt (>= 1.0, < 3.0)
24
+ multi_xml (~> 0.5)
25
+ rack (>= 1.2, < 3)
26
+ snaky_hash (~> 2.0)
27
+ version_gem (~> 1.1)
28
+ omniauth (2.1.0)
29
+ hashie (>= 3.4.6)
30
+ rack (>= 2.2.3)
31
+ rack-protection
32
+ omniauth-oauth2 (1.8.0)
33
+ oauth2 (>= 1.4, < 3)
34
+ omniauth (~> 2.0)
35
+ parallel (1.22.1)
36
+ parser (3.1.2.1)
37
+ ast (~> 2.4.1)
38
+ rack (2.2.4)
39
+ rack-protection (2.2.2)
40
+ rack
41
+ rainbow (3.1.1)
42
+ rake (13.0.6)
43
+ regexp_parser (2.5.0)
44
+ rexml (3.2.5)
45
+ rubocop (1.36.0)
46
+ json (~> 2.3)
47
+ parallel (~> 1.10)
48
+ parser (>= 3.1.2.1)
49
+ rainbow (>= 2.2.2, < 4.0)
50
+ regexp_parser (>= 1.8, < 3.0)
51
+ rexml (>= 3.2.5, < 4.0)
52
+ rubocop-ast (>= 1.20.1, < 2.0)
53
+ ruby-progressbar (~> 1.7)
54
+ unicode-display_width (>= 1.4.0, < 3.0)
55
+ rubocop-ast (1.21.0)
56
+ parser (>= 3.1.1.0)
57
+ ruby-progressbar (1.11.0)
58
+ ruby2_keywords (0.0.5)
59
+ snaky_hash (2.0.0)
60
+ hashie
61
+ version_gem (~> 1.1)
62
+ unicode-display_width (2.2.0)
63
+ version_gem (1.1.0)
64
+
65
+ PLATFORMS
66
+ x86_64-linux
67
+
68
+ DEPENDENCIES
69
+ omniauth-roblox!
70
+ rake
71
+ rubocop (~> 1.36)
72
+
73
+ BUNDLED WITH
74
+ 2.3.21
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Wolftallemo
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 all
13
+ 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 THE
21
+ SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require 'bundler/gem_tasks'
@@ -0,0 +1,99 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'json'
4
+ require 'jwt'
5
+ require 'net/http'
6
+ require 'omniauth/strategies/oauth2'
7
+ require 'uri'
8
+
9
+ module OmniAuth
10
+ module Strategies
11
+ # This is the Roblox OAuth/OIDC strategy
12
+ # Currently their API is in private beta
13
+ # If you are enrolled, you may register
14
+ # at https://create.roblox.com/credentials
15
+ class Roblox < OmniAuth::Strategies::OAuth2
16
+ option :name, 'roblox'
17
+
18
+ option :client_options,
19
+ authorize_url: 'https://authorize.roblox.com/',
20
+ site: 'https://apis.roblox.com/oauth',
21
+ token_url: 'v1/token'
22
+
23
+ option :jwt_leeway, 60
24
+ option :authorize_options, %i[consent login selectAccount]
25
+ option :image_type, 'headshot'
26
+ option :skip_image, false
27
+
28
+ def authorize_params # rubocop:disable Metrics/AbcSize
29
+ super.tap do |params|
30
+ options[:authorize_options].each do |k|
31
+ params[k] = request.params[k.to_s] unless [nil, ''].include?(request.params[k.to_s])
32
+ end
33
+
34
+ session['omniauth.state'] = params[:state] if params[:state]
35
+ end
36
+ end
37
+
38
+ uid { raw_info['sub'] }
39
+
40
+ info do
41
+ {
42
+ name: raw_info['name'],
43
+ email: "#{SecureRandom.hex(18)}@notre.al",
44
+ nickname: user_info['nickname'],
45
+ image: image_url,
46
+ # This is provided in the `profile` claim, but is not included if the `profile` scope is not set
47
+ urls: { website: "https://www.roblox.com/users/#{uid}/profile" }
48
+ }
49
+ end
50
+
51
+ extra do
52
+ { raw_info: raw_info }
53
+ end
54
+
55
+ def raw_info
56
+ @raw_info ||= ::JWT.decode(access_token['id_token'], nil, false).first
57
+
58
+ return if @raw_info['name']
59
+
60
+ user_api_res = Net::HTTP.get_response(URI("https://users.roblox.com/v1/users/#{uid}"))
61
+
62
+ # The Roblox Users API returns usernames under the `name` property
63
+ # Unlike the id_token where it is the display name
64
+ return unless user_api_res.is_a?(Net::HTTPSuccess)
65
+
66
+ api_data = JSON.parse(user_api_res.body)
67
+ @raw_info['nickname'] = api_data['name']
68
+ @raw_info['name'] = api_data['displayName']
69
+ end
70
+
71
+ # Roblox currently does not allow third parties to access user emails, this is only added for completeness
72
+ def verified_email
73
+ raw_info['email_verified'] ? raw_info['email'] : nil
74
+ end
75
+
76
+ def image_url # rubocop:disable Metrics
77
+ return nil if options[:skip_image]
78
+
79
+ url = 'https://thumbnails.roblox.com/v1/users/avatar'
80
+ url_additions = {
81
+ bust: '-bust',
82
+ headshot: '-headshot'
83
+ }
84
+ uri = URI(url + url_additions[options[:image_type]])
85
+ uri.query = URI.encode_www_form({
86
+ userIds: raw_info['sub'],
87
+ size: '720x720',
88
+ format: 'Png',
89
+ isCircular: 'false'
90
+ })
91
+
92
+ res = Net::HTTP.get_response(uri)
93
+ data = JSON.parse(res.body).data.first
94
+
95
+ res.is_a?(Net::HTTPSuccess) ? data.imageUrl : nil
96
+ end
97
+ end
98
+ end
99
+ end
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module Roblox
3
+ VERSION = '0.0.1'
4
+ end
5
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'omniauth-roblox/version'
4
+ require 'omniauth/strategies/roblox'
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require File.expand_path('lib/omniauth-roblox/version', __dir__)
4
+
5
+ Gem::Specification.new do |gem|
6
+ gem.authors = ['Wolftallemo']
7
+ gem.files = `git ls-files`.split("\n")
8
+ gem.homepage = 'https://github.com/Wolftallemo/omniauth-roblox'
9
+ gem.license = 'MIT'
10
+ gem.name = 'omniauth-roblox'
11
+ gem.required_ruby_version = '>= 2.7.2'
12
+ gem.summary = 'OmniAuth strategy for Roblox'
13
+ gem.version = OmniAuth::Roblox::VERSION
14
+
15
+ gem.add_dependency 'jwt', '~> 2.5'
16
+ gem.add_dependency 'omniauth', '~> 2.1'
17
+ gem.add_dependency 'omniauth-oauth2', '~> 1.8'
18
+ end
metadata ADDED
@@ -0,0 +1,92 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-roblox
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Wolftallemo
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-09-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: jwt
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.5'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: omniauth
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.1'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.1'
41
+ - !ruby/object:Gem::Dependency
42
+ name: omniauth-oauth2
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.8'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.8'
55
+ description:
56
+ email:
57
+ executables: []
58
+ extensions: []
59
+ extra_rdoc_files: []
60
+ files:
61
+ - Gemfile
62
+ - Gemfile.lock
63
+ - LICENSE
64
+ - Rakefile
65
+ - lib/omniauth-roblox.rb
66
+ - lib/omniauth-roblox/omniauth/strategies/roblox.rb
67
+ - lib/omniauth-roblox/version.rb
68
+ - omniauth-roblox.gemspec
69
+ homepage: https://github.com/Wolftallemo/omniauth-roblox
70
+ licenses:
71
+ - MIT
72
+ metadata: {}
73
+ post_install_message:
74
+ rdoc_options: []
75
+ require_paths:
76
+ - lib
77
+ required_ruby_version: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: 2.7.2
82
+ required_rubygems_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ requirements: []
88
+ rubygems_version: 3.3.22
89
+ signing_key:
90
+ specification_version: 4
91
+ summary: OmniAuth strategy for Roblox
92
+ test_files: []