omniauth-kit-oauth2 0.1.3

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: 8529d5736ce74dc031be2f0e5cffc87d20b5c3ce38af408eab6f3b711fb332a8
4
+ data.tar.gz: 8ef2571312d7fe0b212a85c68160f7c2c0af2faf5c3bdec3650a3315d79fd227
5
+ SHA512:
6
+ metadata.gz: 1a1155fd0db3d54be69f7d7ac95f5515a0f18128c0d6e4fa31e994733f136e1a4e0a1c25bec71f11edfbb5b3825e15fc30c65eda4d42f00643b380722676037c
7
+ data.tar.gz: 1dc9fbd6350fb01d12aa91b890f6e67bf871faa261fad44c3c04cadf7d4d4882bc354efe0e7ca19e73a421ae2c5ef87b2b41d23d383bb0991e20ed913619e356
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+ Copyright (c) 2025 Kit
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the "Software"), to deal
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is
9
+ furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all
12
+ copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,70 @@
1
+ # OmniAuth Kit OAuth2 Strategy
2
+
3
+ Strategy to authenticate with Kit via OAuth2 in OmniAuth.
4
+
5
+ Get your API key at: https://app.kit.com/account_settings/developer_settings Note the Client ID and the Client Secret.
6
+
7
+ For more details, read the Developer docs: https://developers.kit.com/v4
8
+
9
+ ## Installation
10
+
11
+ Add to your `Gemfile`:
12
+
13
+ ```ruby
14
+ gem 'omniauth-kit-oauth2'
15
+ ```
16
+
17
+ Then `bundle install`.
18
+
19
+ ## Usage
20
+
21
+ Here's an example for adding the middleware to a Rails app in `config/initializers/omniauth.rb`:
22
+
23
+ ```ruby
24
+ Rails.application.config.middleware.use OmniAuth::Builder do
25
+ provider :kit_oauth2, client_id: ENV.fetch("KIT_CLIENT_ID"),
26
+ client_secret: ENV.fetch("KIT_CLIENT_SECRET")
27
+ end
28
+ ```
29
+
30
+ You can now access the OmniAuth Kit OAuth2 URL: `/auth/kit_oauth2`
31
+
32
+ ## Auth Hash
33
+
34
+ Here's an example of an authentication hash available in the callback by accessing `request.env['omniauth.auth']`:
35
+
36
+ ```ruby
37
+ {
38
+ "provider" => "kit_oauth2",
39
+ "uid" => 1,
40
+ "info" => {
41
+ "name" => "Creator",
42
+ "email" => "creator@example.com"
43
+ },
44
+ "credentials" => {
45
+ "token" => "abc123",
46
+ "refresh_token" => "def456",
47
+ "expires_at" => 123,
48
+ "expires" => true
49
+ },
50
+ "extra" => {
51
+ "raw_info" => {
52
+ "user" => {
53
+ "email" => "test@example.com"
54
+ },
55
+ "account" => {
56
+ "name" => "Kit Greetings",
57
+ "plan_type" => "creator",
58
+ "primary_email_address" => "test@example.com",
59
+ "created_at" => "2023-02-17T11:43:55Z",
60
+ "id" => 26
61
+ }
62
+ }
63
+ }
64
+ }
65
+ ```
66
+
67
+ ## Publishing
68
+
69
+ New versions are automatically published on push to main if
70
+ lib/omniauth/kit_oauth2/version.rb is bumped.
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/setup"
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,7 @@
1
+ module Omniauth
2
+ module Kit
3
+ module Oauth2
4
+ VERSION = "0.1.3"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,34 @@
1
+ require "omniauth"
2
+ require "omniauth-oauth2"
3
+
4
+ module OmniAuth
5
+ module Strategies
6
+ class KitOauth2 < OmniAuth::Strategies::OAuth2
7
+ option :name, "kit_oauth2"
8
+ option :client_options, { site: "https://app.kit.com", api_site: "https://api.kit.com" }
9
+
10
+ uid do
11
+ raw_info["account"]["id"]
12
+ end
13
+
14
+ info do
15
+ {
16
+ name: raw_info["account"]["name"],
17
+ email: raw_info["account"]["primary_email_address"]
18
+ }
19
+ end
20
+
21
+ extra do
22
+ { raw_info: }
23
+ end
24
+
25
+ def raw_info
26
+ @raw_info ||= access_token.get("#{options["client_options"]["api_site"]}/v4/account").parsed
27
+ end
28
+
29
+ def authorize_params
30
+ super.merge(tenant_name: request.params["tenant_name"])
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1 @@
1
+ require "omniauth/strategies/kit_oauth2"
metadata ADDED
@@ -0,0 +1,121 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-kit-oauth2
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.3
5
+ platform: ruby
6
+ authors:
7
+ - Kit
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2025-02-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: omniauth
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.1'
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'
27
+ - !ruby/object:Gem::Dependency
28
+ name: omniauth-oauth2
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.8'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.8'
41
+ - !ruby/object:Gem::Dependency
42
+ name: debug
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.10'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.10'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.13'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.13'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '13.2'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '13.2'
83
+ description:
84
+ email:
85
+ - engineering@kit.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - LICENSE
91
+ - README.md
92
+ - Rakefile
93
+ - lib/omniauth-kit-oauth2.rb
94
+ - lib/omniauth/kit_oauth2/version.rb
95
+ - lib/omniauth/strategies/kit_oauth2.rb
96
+ homepage: https://developers.kit.com
97
+ licenses: []
98
+ metadata:
99
+ homepage_uri: https://developers.kit.com
100
+ source_code_uri: https://github.com/Kit/omniauth-kit-oauth2/
101
+ changelog_uri: https://github.com/Kit/omniauth-kit-oauth2/
102
+ post_install_message:
103
+ rdoc_options: []
104
+ require_paths:
105
+ - lib
106
+ required_ruby_version: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ required_rubygems_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ requirements: []
117
+ rubygems_version: 3.5.22
118
+ signing_key:
119
+ specification_version: 4
120
+ summary: Allows authenticating with Kit V4 API.
121
+ test_files: []