omniauth-kick 0.1.0

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: 8ac59985ea17ac5c8be6cdc5312f15de8bdab09c056c5fd7b96c3212545c1d5c
4
+ data.tar.gz: 5240afc89c5d218eca8d590c6cb98c7b6010a83c8cf7a3f5ba8da6ae95bd3ef9
5
+ SHA512:
6
+ metadata.gz: 3e5a5799ca4fec5f51b57c2e9a0818e8ecd7aa27836d0ea265b9762a8e23a02ccc2592ffccbd4b8a1d12eba895732e31405b5e909251f16910a45ff0a54211cc
7
+ data.tar.gz: 8833cc385fbfd7af93cd0004d4aec74661723f48e1e0579eb6e3bcd3f7ecd5904b191e912f8c2d38528856833c343f1cce8de9d8d7a911107748d9a8ae9a6a12
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in omniauth-twitch.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2025 Dean Perry
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,44 @@
1
+ # OmniAuth::Kick
2
+
3
+ A OmniAuth strategy for Kick
4
+
5
+ ## Installation
6
+
7
+ Add the OmniAuth Kick and OmniAuth `rails_csrf_protection` gems to your Gemfile
8
+
9
+ ```ruby
10
+ gem 'omniauth-kick'
11
+ gem 'omniauth-rails_csrf_protection'
12
+ ```
13
+
14
+ ## Usage
15
+
16
+ Here's an example for adding the middleware to a Rails app in `config/initializers/omniauth.rb`:
17
+
18
+ ```ruby
19
+ Rails.application.config.middleware.use OmniAuth::Builder do
20
+ provider :kick, ENV["KICK_CLIENT_ID"], ENV["KICK_CLIENT_SECRET"]
21
+ end
22
+ ```
23
+
24
+ ## Auth Hash
25
+
26
+ Here's an example *Auth Hash* available in `request.env['omniauth.auth']`:
27
+
28
+ ```ruby
29
+ {
30
+ provider: 'kick',
31
+ uid: '12345678',
32
+ info: {
33
+ name: 'JohnDoe',
34
+ email: 'johndoe@gmail.com',
35
+ image: 'https://kick.com/img/default-profile-pictures/default-avatar-6.webp',
36
+ url: 'https://kick.com/johndoe'
37
+ },
38
+ credentials: {
39
+ token: 'asdfghjklasdfghjklasdfghjkl', # OAuth 2.0 access_token, which you may wish to store
40
+ expires: false # this will always be false,
41
+ refresh_token: 'asdschbjh24h23yfsjfhbsjdc3a' # OAuth 2.0 refresh token, to renew the access token when it expires
42
+ }
43
+ }
44
+ ```
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module Kick
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,2 @@
1
+ require "omniauth/kick/version"
2
+ require 'omniauth/strategies/kick'
@@ -0,0 +1,117 @@
1
+ require 'omniauth-oauth2'
2
+ require 'securerandom'
3
+ require 'digest'
4
+
5
+ module OmniAuth
6
+ module Strategies
7
+ class Kick < OmniAuth::Strategies::OAuth2
8
+ DEFAULT_SCOPE = "user:read".freeze
9
+
10
+ option :name, "kick"
11
+
12
+ option :client_options, {
13
+ site: "https://id.kick.com",
14
+ authorize_url: "/oauth/authorize",
15
+ token_url: "/oauth/token"
16
+ }
17
+
18
+ option :access_token_options, {
19
+ header_format: "Bearer %s",
20
+ param_name: "access_token"
21
+ }
22
+
23
+ option :authorize_options, [:scope]
24
+
25
+ def request_phase
26
+ redirect client.auth_code.
27
+ authorize_url({ redirect_uri: callback_url }.merge(authorize_params)).
28
+ gsub(/%2[b,B]/, "+")
29
+ end
30
+
31
+ credentials do
32
+ hash = { "token" => access_token.token }
33
+ if access_token.refresh_token
34
+ hash["refresh_token"] = access_token.refresh_token
35
+ end
36
+ hash["expires_at"] = access_token.expires_at if access_token.expires?
37
+ hash["expires"] = access_token.expires?
38
+ hash
39
+ end
40
+
41
+ uid { raw_info["user_id"] }
42
+
43
+ info do
44
+ {
45
+ name: raw_info["name"],
46
+ email: raw_info["email"],
47
+ image: raw_info["profile_picture"],
48
+ url: "https://kick.com/#{raw_info['name']}"
49
+ }
50
+ end
51
+
52
+ def raw_info
53
+ @raw_info ||=
54
+ access_token.get("https://api.kick.com/public/v1/users").parsed.
55
+ fetch("data").fetch(0)
56
+ end
57
+
58
+ def build_access_token
59
+ verifier = code_verifier
60
+ client.auth_code.get_token(
61
+ request.params['code'],
62
+ {
63
+ redirect_uri: callback_url,
64
+ code_verifier: verifier
65
+ }.merge(token_params),
66
+ deep_symbolize(options.auth_token_params)
67
+ )
68
+ end
69
+
70
+ def access_token_options
71
+ options.access_token_options.inject({}) { |h,(k,v)| h[k.to_sym] = v; h }
72
+ end
73
+
74
+ def callback_url
75
+ return options[:redirect_uri] unless options[:redirect_uri].nil?
76
+ full_host + script_name + callback_path
77
+ end
78
+
79
+ def authorize_params
80
+ super.tap do |params|
81
+ options[:authorize_options].each do |k|
82
+ params[k] = request.params[k.to_s] unless [nil, ''].include?(request.params[k.to_s])
83
+ end
84
+ params[:scope] = params[:scope] || DEFAULT_SCOPE
85
+ params[:code_challenge] = generate_code_challenge
86
+ params[:code_challenge_method] = "S256"
87
+ end
88
+ end
89
+
90
+ private
91
+
92
+ def generate_code_challenge
93
+ verifier = code_verifier
94
+ Digest::SHA256.base64digest(verifier).tr('+/', '-_').tr('=', '')
95
+ end
96
+
97
+ def code_verifier
98
+ "To verify PKCE challenge code created"
99
+ end
100
+
101
+ def token_params
102
+ {
103
+ grant_type: 'authorization_code',
104
+ client_id: client.id,
105
+ client_secret: client.secret,
106
+ redirect_uri: callback_url
107
+ }
108
+ end
109
+
110
+ def deep_symbolize(hash)
111
+ hash.each_with_object({}) do |(key, value), result|
112
+ result[key.to_sym] = value.is_a?(Hash) ? deep_symbolize(value) : value
113
+ end
114
+ end
115
+ end
116
+ end
117
+ end
@@ -0,0 +1 @@
1
+ require 'omniauth/kick'
@@ -0,0 +1,19 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'omniauth/kick/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "omniauth-kick"
8
+ spec.version = OmniAuth::Kick::VERSION
9
+ spec.authors = ["Dean Perry"]
10
+ spec.email = ["dean@deanpcmad.com"]
11
+ spec.summary = "Kick OAuth2 Strategy for OmniAuth"
12
+ spec.homepage = "https://github.com/deanpcmad/omniauth-kick"
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files`.split($/)
16
+ spec.require_paths = ["lib"]
17
+
18
+ spec.add_runtime_dependency 'omniauth-oauth2', '~> 1.8'
19
+ end
metadata ADDED
@@ -0,0 +1,63 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-kick
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Dean Perry
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: omniauth-oauth2
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - "~>"
17
+ - !ruby/object:Gem::Version
18
+ version: '1.8'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - "~>"
24
+ - !ruby/object:Gem::Version
25
+ version: '1.8'
26
+ email:
27
+ - dean@deanpcmad.com
28
+ executables: []
29
+ extensions: []
30
+ extra_rdoc_files: []
31
+ files:
32
+ - ".gitignore"
33
+ - Gemfile
34
+ - LICENSE.txt
35
+ - README.md
36
+ - Rakefile
37
+ - lib/omniauth-kick.rb
38
+ - lib/omniauth/kick.rb
39
+ - lib/omniauth/kick/version.rb
40
+ - lib/omniauth/strategies/kick.rb
41
+ - omniauth-kick.gemspec
42
+ homepage: https://github.com/deanpcmad/omniauth-kick
43
+ licenses:
44
+ - MIT
45
+ metadata: {}
46
+ rdoc_options: []
47
+ require_paths:
48
+ - lib
49
+ required_ruby_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ required_rubygems_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
59
+ requirements: []
60
+ rubygems_version: 3.6.9
61
+ specification_version: 4
62
+ summary: Kick OAuth2 Strategy for OmniAuth
63
+ test_files: []