omniauth-goodgame 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: ea96d28ff6cb17a14875bd9d9a97c48d6a4c8dd4d85d23652e2cfb6aa86191a8
4
+ data.tar.gz: 5100dedff74af0aac75a9d3c20f3c21d3fb03bdfc80dbe09475454a831d8c7bb
5
+ SHA512:
6
+ metadata.gz: 4cd75d74fbdb0ed25291ba32b7f859c08614c1c929dec38813f048f6d2ac4dc05df4caaa11f445d18c959e7c89b568a0deb99981d526cd1356d8455efe028408
7
+ data.tar.gz: 121cbcdec97a73aae4fd784d18c4f8d97c806f004a4b7efed9d60340bf1345eeaae7a0eb5b60e958b7fff9be4a27cded87a1ffe9a032e59bca68f2929b437842
@@ -0,0 +1,27 @@
1
+ name: Ruby
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+
8
+ pull_request:
9
+
10
+ jobs:
11
+ build:
12
+ runs-on: ubuntu-latest
13
+ name: Ruby ${{ matrix.ruby }}
14
+ strategy:
15
+ matrix:
16
+ ruby:
17
+ - '3.1.0'
18
+
19
+ steps:
20
+ - uses: actions/checkout@v2
21
+ - name: Set up Ruby
22
+ uses: ruby/setup-ruby@v1
23
+ with:
24
+ ruby-version: ${{ matrix.ruby }}
25
+ bundler-cache: true
26
+ - name: Run the default task
27
+ run: bundle exec rake
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/.rubocop.yml ADDED
@@ -0,0 +1,13 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.6
3
+
4
+ Style/StringLiterals:
5
+ Enabled: true
6
+ EnforcedStyle: double_quotes
7
+
8
+ Style/StringLiteralsInInterpolation:
9
+ Enabled: true
10
+ EnforcedStyle: double_quotes
11
+
12
+ Layout/LineLength:
13
+ Max: 120
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in omniauth-goodgame.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "rubocop", "~> 1.21"
data/Gemfile.lock ADDED
@@ -0,0 +1,76 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ omniauth-goodgame (0.0.3)
5
+ omniauth-oauth2 (~> 1.6)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ ast (2.4.2)
11
+ base64 (0.1.1)
12
+ faraday (2.7.11)
13
+ base64
14
+ faraday-net_http (>= 2.0, < 3.1)
15
+ ruby2_keywords (>= 0.0.4)
16
+ faraday-net_http (3.0.2)
17
+ hashie (5.0.0)
18
+ json (2.6.1)
19
+ jwt (2.7.1)
20
+ multi_xml (0.6.0)
21
+ oauth2 (2.0.9)
22
+ faraday (>= 0.17.3, < 3.0)
23
+ jwt (>= 1.0, < 3.0)
24
+ multi_xml (~> 0.5)
25
+ rack (>= 1.2, < 4)
26
+ snaky_hash (~> 2.0)
27
+ version_gem (~> 1.1)
28
+ omniauth (2.1.1)
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.23.0)
36
+ parser (3.2.2.3)
37
+ ast (~> 2.4.1)
38
+ racc
39
+ racc (1.6.0)
40
+ rack (2.2.8)
41
+ rack-protection (3.1.0)
42
+ rack (~> 2.2, >= 2.2.4)
43
+ rainbow (3.1.1)
44
+ rake (13.0.6)
45
+ regexp_parser (2.8.1)
46
+ rexml (3.2.5)
47
+ rubocop (1.51.0)
48
+ json (~> 2.3)
49
+ parallel (~> 1.10)
50
+ parser (>= 3.2.0.0)
51
+ rainbow (>= 2.2.2, < 4.0)
52
+ regexp_parser (>= 1.8, < 3.0)
53
+ rexml (>= 3.2.5, < 4.0)
54
+ rubocop-ast (>= 1.28.0, < 2.0)
55
+ ruby-progressbar (~> 1.7)
56
+ unicode-display_width (>= 2.4.0, < 3.0)
57
+ rubocop-ast (1.29.0)
58
+ parser (>= 3.2.1.0)
59
+ ruby-progressbar (1.13.0)
60
+ ruby2_keywords (0.0.5)
61
+ snaky_hash (2.0.1)
62
+ hashie
63
+ version_gem (~> 1.1, >= 1.1.1)
64
+ unicode-display_width (2.4.2)
65
+ version_gem (1.1.3)
66
+
67
+ PLATFORMS
68
+ x86_64-linux
69
+
70
+ DEPENDENCIES
71
+ omniauth-goodgame!
72
+ rake (~> 13.0)
73
+ rubocop (~> 1.21)
74
+
75
+ BUNDLED WITH
76
+ 2.3.3
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023 Alex Seregin
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,43 @@
1
+ # Omniauth::Goodgame
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/omniauth/goodgame`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'omniauth-goodgame'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle install
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install omniauth-goodgame
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/omniauth-goodgame. 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/[USERNAME]/omniauth-goodgame/blob/master/CODE_OF_CONDUCT.md).
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
40
+
41
+ ## Code of Conduct
42
+
43
+ Everyone interacting in the Omniauth::Goodgame project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/omniauth-goodgame/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Omniauth
4
+ module Goodgame
5
+ VERSION = "0.0.3"
6
+ end
7
+ end
@@ -0,0 +1,2 @@
1
+ require "omniauth/goodgame/version"
2
+ require 'omniauth/strategies/goodgame'
@@ -0,0 +1,88 @@
1
+ require "omniauth-oauth2"
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class GoodGame < OmniAuth::Strategies::OAuth2
6
+ DEFAULT_SCOPE = ""
7
+ option :name, "goodgame"
8
+
9
+ option :client_options, {
10
+ site: "https://goodgame.ru",
11
+ authorize_url: "/oauth2/authorize",
12
+ token_url: "/oauth2/token",
13
+ auth_scheme: :request_body
14
+ }
15
+
16
+ option :access_token_options, {
17
+ header_format: "application/x-www-form-urlencoded",
18
+ param_name: "access_token"
19
+ }
20
+
21
+ option :authorize_options, [:scope]
22
+
23
+ def request_phase
24
+ redirect client.auth_code
25
+ .authorize_url({ redirect_uri: callback_url }
26
+ .merge(authorize_params)).gsub(/%2[b,B]/, "+")
27
+ end
28
+
29
+ credentials do
30
+ hash = { "token" => access_token.token }
31
+ hash["refresh_token"] = access_token.refresh_token if access_token.refresh_token
32
+ hash["expires_at"] = access_token.expires_at if access_token.expires?
33
+ hash["expires"] = access_token.expires?
34
+ hash
35
+ end
36
+
37
+ uid { raw_info["id"] }
38
+
39
+ info do
40
+ {
41
+ name: raw_info["nickname"],
42
+ email: raw_info["email"],
43
+ nickname: raw_info["username"],
44
+ description: raw_info["about"],
45
+ image: raw_info["avatar"],
46
+ urls: { Goodgame: raw_info["link"] }
47
+ }
48
+ end
49
+ extra do
50
+ {
51
+ raw_info: raw_info
52
+ }
53
+ end
54
+ def raw_info
55
+ @raw_info ||=
56
+ access_token.get("https://goodgame.ru/api/4/users/#{client.id}").parsed
57
+ .fetch("data").fetch(0)
58
+ end
59
+
60
+ def build_access_token
61
+ super.tap do |token|
62
+ token.options.merge!(access_token_options)
63
+ end
64
+ end
65
+
66
+ def access_token_options
67
+ options.access_token_options.each_with_object({}) do |(k, v), h|
68
+ h[k.to_sym] = v
69
+ end
70
+ end
71
+
72
+ def callback_url
73
+ return options[:redirect_uri] unless options[:redirect_uri].nil?
74
+
75
+ full_host + script_name + callback_path
76
+ end
77
+
78
+ def authorize_params
79
+ super.tap do |params|
80
+ options[:authorize_options].each do |k|
81
+ params[k] = request.params[k.to_s] unless [nil, ""].include?(request.params[k.to_s])
82
+ end
83
+ params[:scope] = params[:scope] || DEFAULT_SCOPE
84
+ end
85
+ end
86
+ end
87
+ end
88
+ end
@@ -0,0 +1 @@
1
+ require 'omniauth/goodgame'
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require_relative "lib/omniauth/goodgame/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "omniauth-goodgame"
8
+ spec.version = Omniauth::Goodgame::VERSION
9
+ spec.authors = ["Alex Seregin"]
10
+ spec.email = ["quqiedeep@gmail.com"]
11
+
12
+ spec.summary = "GoodGame OAuth2 Strategy for OmniAuth."
13
+ spec.homepage = "https://github.com/Alex1324522/omniauth-goodgame"
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = ">= 2.6.0"
16
+
17
+ # Specify which files should be added to the gem when it is released.
18
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
19
+ spec.files = `git ls-files`.split($/)
20
+ spec.require_paths = ["lib"]
21
+ spec.add_runtime_dependency "omniauth-oauth2", "~> 1.6"
22
+
23
+ # Uncomment to register a new dependency of your gem
24
+ # spec.add_dependency "example-gem", "~> 1.0"
25
+
26
+ # For more information and examples about making a new gem, check out our
27
+ # guide at: https://bundler.io/guides/creating_gem.html
28
+ end
metadata ADDED
@@ -0,0 +1,69 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-goodgame
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
5
+ platform: ruby
6
+ authors:
7
+ - Alex Seregin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2023-09-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: omniauth-oauth2
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ description:
28
+ email:
29
+ - quqiedeep@gmail.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".github/workflows/main.yml"
35
+ - ".gitignore"
36
+ - ".rubocop.yml"
37
+ - Gemfile
38
+ - Gemfile.lock
39
+ - LICENSE.txt
40
+ - README.md
41
+ - lib/omniauth-goodgame.rb
42
+ - lib/omniauth/goodgame.rb
43
+ - lib/omniauth/goodgame/version.rb
44
+ - lib/omniauth/strategies/goodgame.rb
45
+ - omniauth-goodgame.gemspec
46
+ homepage: https://github.com/Alex1324522/omniauth-goodgame
47
+ licenses:
48
+ - MIT
49
+ metadata: {}
50
+ post_install_message:
51
+ rdoc_options: []
52
+ require_paths:
53
+ - lib
54
+ required_ruby_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: 2.6.0
59
+ required_rubygems_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ requirements: []
65
+ rubygems_version: 3.3.3
66
+ signing_key:
67
+ specification_version: 4
68
+ summary: GoodGame OAuth2 Strategy for OmniAuth.
69
+ test_files: []