omniauth-figma-oauth2 1.0.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: 35812759a8cce30338e2eb7a86c3d5c10f572424188b366b48697466de0f8c7f
4
+ data.tar.gz: 382df3bca3150a689ef5bdb5aedaac753afab1ec01eb520255f9994aa76cd10c
5
+ SHA512:
6
+ metadata.gz: 8f159e5cd8ab7c5d669f66245ab854f8cf2a2d71cf7b02d6cf08b01c451e2f9e5a4682bb68539146dac146f62f3a6f78510957aa2c79035b15db5ef14d2078f3
7
+ data.tar.gz: 35563d93fa2b103b8841a599def47094ceba0cb2f589240b3b6eb1c68eb47228d40531cb92cd583b023874b6c46a0476f59f63000a5cff9f82a7054fca2ca2d7
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [1.0.0] - 2024-08-22
4
+
5
+ - Initial release
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in omniauth-figma.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2024 Philipp Riedel
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,75 @@
1
+ <div align="center">
2
+ <img src="https://upload.wikimedia.org/wikipedia/commons/thumb/3/33/Figma-logo.svg/400px-Figma-logo.svg.png" width="80">
3
+
4
+ # OmniAuth Figma
5
+ A Figma OAuth2 strategy for OmniAuth.
6
+
7
+ </div>
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ gem 'omniauth-figma-oauth2'
14
+ gem 'omniauth-rails_csrf_protection'
15
+
16
+ And then execute:
17
+
18
+ $ bundle
19
+
20
+ Or install it yourself as:
21
+
22
+ $ gem install omniauth-figma-oauth2
23
+
24
+
25
+ ## Usage
26
+
27
+ Register your application with Figma to receive your Client ID and Secret key: https://www.figma.com/developers/apps
28
+
29
+ This is an example that you might put into a Rails initializer at `config/initializers/omniauth.rb`:
30
+
31
+ ```ruby
32
+ Rails.application.config.middleware.use OmniAuth::Builder do
33
+ provider :figma, ENV['CLIENT_ID'], ENV['CLIENT_SECRET']
34
+ end
35
+ ```
36
+
37
+ You can now access the OmniAuth Figma OAuth2 URL: `/auth/figma`.
38
+
39
+ Make sure that all links to /auth/figma use POST requests. For example:
40
+ ```ruby
41
+ link_to 'Sign in via Figma', '/auth/figma', method: :post
42
+ # or
43
+ button_to 'Sign in via Figma', '/auth/figma'
44
+ ```
45
+
46
+ For more info check: https://github.com/omniauth/omniauth/wiki/Resolving-CVE-2015-9284
47
+
48
+
49
+ ## Auth Hash
50
+ Here's an example *Auth Hash* available in `request.env['omniauth.auth']`:
51
+
52
+ ```ruby
53
+ {
54
+ provider: 'figma',
55
+ uid: '510245748683192988',
56
+ info: {
57
+ email: 'john@doe.com',
58
+ name: 'John',
59
+ image: 'https://s3-alpha.figma.com/static/user_j.png',
60
+ },
61
+ credentials: {
62
+ access_token: '<TOKEN>',
63
+ expires_in: '<EXPIRATION (in seconds)>',
64
+ refresh_token: 'refresh_token'
65
+ }
66
+ }
67
+ ```
68
+
69
+ ## Contributing
70
+
71
+ Bug reports and pull requests are welcome on GitHub at https://github.com/phiele/omniauth-figma-oauth2.
72
+
73
+ ## License
74
+
75
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: %i[spec]
data/bin/console ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "omniauth/figma"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ require "irb"
10
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,48 @@
1
+ require 'omniauth-oauth2'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class Figma < OmniAuth::Strategies::OAuth2
6
+
7
+ option :name, 'figma'
8
+ option :scope, 'file_read'
9
+
10
+ option :client_options, {
11
+ site: 'https://www.figma.com',
12
+ authorize_url: '/oauth',
13
+ token_url: '/api/oauth/token'
14
+ }
15
+
16
+ option :token_options, [:client_id, :client_secret]
17
+ option :token_params, { parse: :json }
18
+
19
+ uid { raw_info['id'].to_s }
20
+
21
+ info do
22
+ {
23
+ :name => raw_info['handle'],
24
+ :email => raw_info['email'],
25
+ :image => raw_info['img_url']
26
+ }
27
+ end
28
+
29
+ credentials do
30
+ {
31
+ :access_token => access_token.token,
32
+ :expires_at => access_token.expires_at,
33
+ :expires => access_token.expires?,
34
+ :refresh_token => access_token.refresh_token
35
+ }
36
+ end
37
+
38
+ def raw_info
39
+ @raw_info = access_token.get('https://api.figma.com/v1/me').parsed
40
+ end
41
+
42
+ def callback_url
43
+ full_host + script_name + callback_path
44
+ end
45
+
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,5 @@
1
+ module Omniauth
2
+ module Figma
3
+ VERSION = "1.0.0"
4
+ end
5
+ end
@@ -0,0 +1,2 @@
1
+ require "omniauth-figma/version"
2
+ require "omniauth/strategies/figma"
@@ -0,0 +1,41 @@
1
+ lib = File.expand_path("../lib", __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+
4
+ require "omniauth-figma/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "omniauth-figma-oauth2"
8
+ spec.version = Omniauth::Figma::VERSION
9
+ spec.authors = ["Philipp Riedel"]
10
+ spec.email = ["riedel.philipp@gmx.net"]
11
+ spec.summary = "Figma OAuth2 strategy for OmniAuth"
12
+ spec.description = "Figma OAuth2 strategy for OmniAuth"
13
+ spec.homepage = "https://github.com/phiele/omniauth-figma-oauth2"
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 = Dir['lib/**/*.rb'] + Dir['bin/*']
20
+ spec.files += Dir['[A-Z]*']
21
+ spec.files.reject! { |fn| fn.include? "CVS" }
22
+ spec.bindir = "exe"
23
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
24
+ spec.require_paths = ["lib"]
25
+
26
+
27
+ # Register dependencies for this gem
28
+ spec.add_dependency "omniauth-oauth2", "~> 1.8"
29
+ spec.add_dependency "omniauth", "~> 2.1"
30
+
31
+ # Add development dependencies
32
+ spec.add_development_dependency "bundler", "~> 2.4", ">= 2.4.20"
33
+ spec.add_development_dependency "rake", "~> 13.2", ">= 13.2.1"
34
+ spec.add_development_dependency "rspec", "~> 3.1", ">= 3.1.2"
35
+ spec.add_development_dependency "rack-test", "~> 2.1.0"
36
+ spec.add_development_dependency "simplecov", "~> 0.22.0"
37
+ spec.add_development_dependency "webmock", "~> 3.23.1"
38
+
39
+ # For more information and examples about making a new gem, check out our
40
+ # guide at: https://bundler.io/guides/creating_gem.html
41
+ end
metadata ADDED
@@ -0,0 +1,184 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-figma-oauth2
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Philipp Riedel
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2024-08-22 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.8'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.8'
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: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.4'
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: 2.4.20
51
+ type: :development
52
+ prerelease: false
53
+ version_requirements: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - "~>"
56
+ - !ruby/object:Gem::Version
57
+ version: '2.4'
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: 2.4.20
61
+ - !ruby/object:Gem::Dependency
62
+ name: rake
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '13.2'
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: 13.2.1
71
+ type: :development
72
+ prerelease: false
73
+ version_requirements: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - "~>"
76
+ - !ruby/object:Gem::Version
77
+ version: '13.2'
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: 13.2.1
81
+ - !ruby/object:Gem::Dependency
82
+ name: rspec
83
+ requirement: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - "~>"
86
+ - !ruby/object:Gem::Version
87
+ version: '3.1'
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: 3.1.2
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - "~>"
96
+ - !ruby/object:Gem::Version
97
+ version: '3.1'
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: 3.1.2
101
+ - !ruby/object:Gem::Dependency
102
+ name: rack-test
103
+ requirement: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - "~>"
106
+ - !ruby/object:Gem::Version
107
+ version: 2.1.0
108
+ type: :development
109
+ prerelease: false
110
+ version_requirements: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - "~>"
113
+ - !ruby/object:Gem::Version
114
+ version: 2.1.0
115
+ - !ruby/object:Gem::Dependency
116
+ name: simplecov
117
+ requirement: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - "~>"
120
+ - !ruby/object:Gem::Version
121
+ version: 0.22.0
122
+ type: :development
123
+ prerelease: false
124
+ version_requirements: !ruby/object:Gem::Requirement
125
+ requirements:
126
+ - - "~>"
127
+ - !ruby/object:Gem::Version
128
+ version: 0.22.0
129
+ - !ruby/object:Gem::Dependency
130
+ name: webmock
131
+ requirement: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - "~>"
134
+ - !ruby/object:Gem::Version
135
+ version: 3.23.1
136
+ type: :development
137
+ prerelease: false
138
+ version_requirements: !ruby/object:Gem::Requirement
139
+ requirements:
140
+ - - "~>"
141
+ - !ruby/object:Gem::Version
142
+ version: 3.23.1
143
+ description: Figma OAuth2 strategy for OmniAuth
144
+ email:
145
+ - riedel.philipp@gmx.net
146
+ executables: []
147
+ extensions: []
148
+ extra_rdoc_files: []
149
+ files:
150
+ - CHANGELOG.md
151
+ - Gemfile
152
+ - LICENSE.txt
153
+ - README.md
154
+ - Rakefile
155
+ - bin/console
156
+ - bin/setup
157
+ - lib/omniauth-figma-oauth2.rb
158
+ - lib/omniauth-figma/version.rb
159
+ - lib/omniauth/strategies/figma.rb
160
+ - omniauth-figma-oauth2.gemspec
161
+ homepage: https://github.com/phiele/omniauth-figma-oauth2
162
+ licenses:
163
+ - MIT
164
+ metadata: {}
165
+ post_install_message:
166
+ rdoc_options: []
167
+ require_paths:
168
+ - lib
169
+ required_ruby_version: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: 2.6.0
174
+ required_rubygems_version: !ruby/object:Gem::Requirement
175
+ requirements:
176
+ - - ">="
177
+ - !ruby/object:Gem::Version
178
+ version: '0'
179
+ requirements: []
180
+ rubygems_version: 3.4.20
181
+ signing_key:
182
+ specification_version: 4
183
+ summary: Figma OAuth2 strategy for OmniAuth
184
+ test_files: []