omniauth-notion 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 +7 -0
- data/.gitignore +17 -0
- data/.idea/.gitignore +8 -0
- data/.idea/misc.xml +4 -0
- data/.idea/modules.xml +8 -0
- data/.idea/omniauth-notion.iml +24 -0
- data/.idea/vcs.xml +6 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +3 -0
- data/lib/omniauth-notion.rb +72 -0
- data/lib/omniauth-notion/version.rb +7 -0
- data/omniauth-notion.gemspec +23 -0
- metadata +70 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: a7057268fd4eba2d5620dfd38f94411d46f580e767c7555e4a9fbaeada9e96c8
|
4
|
+
data.tar.gz: 2f85909e5bdedc3d057dda1740175317df0bc59b8dd5c14a345e64188ea2ff65
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9bad6a2501283f4cb7992f2729afee24580861fc2094f721be081567aa84b61a014ad9f21fd495eec69725f76cf6bd51231ba2434d0066b56780f4464d30c57a
|
7
|
+
data.tar.gz: cc1831fac34ca7cc1753c044acb6d623f5d891d0ec5eed13bacb771d20dd0eb1c1228efce5741e624859c7e23765bb949bed606356e3aa1ee7c564eb267e56ab
|
data/.gitignore
ADDED
data/.idea/.gitignore
ADDED
data/.idea/misc.xml
ADDED
data/.idea/modules.xml
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<project version="4">
|
3
|
+
<component name="ProjectModuleManager">
|
4
|
+
<modules>
|
5
|
+
<module fileurl="file://$PROJECT_DIR$/.idea/omniauth-notion.iml" filepath="$PROJECT_DIR$/.idea/omniauth-notion.iml" />
|
6
|
+
</modules>
|
7
|
+
</component>
|
8
|
+
</project>
|
@@ -0,0 +1,24 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<module type="RUBY_MODULE" version="4">
|
3
|
+
<component name="ModuleRunConfigurationManager">
|
4
|
+
<shared />
|
5
|
+
</component>
|
6
|
+
<component name="NewModuleRootManager">
|
7
|
+
<content url="file://$MODULE_DIR$">
|
8
|
+
<sourceFolder url="file://$MODULE_DIR$/features" isTestSource="true" />
|
9
|
+
<sourceFolder url="file://$MODULE_DIR$/spec" isTestSource="true" />
|
10
|
+
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
|
11
|
+
</content>
|
12
|
+
<orderEntry type="inheritedJdk" />
|
13
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
14
|
+
<orderEntry type="library" scope="PROVIDED" name="bundler (v2.2.15, rbenv: 2.6.6) [gem]" level="application" />
|
15
|
+
<orderEntry type="library" scope="PROVIDED" name="hashie (v4.1.0, rbenv: 2.6.6) [gem]" level="application" />
|
16
|
+
<orderEntry type="library" scope="PROVIDED" name="omniauth (v1.9.1, rbenv: 2.6.6) [gem]" level="application" />
|
17
|
+
<orderEntry type="library" scope="PROVIDED" name="rack (v2.2.3, rbenv: 2.6.6) [gem]" level="application" />
|
18
|
+
</component>
|
19
|
+
<component name="RakeTasksCache">
|
20
|
+
<option name="myRootTask">
|
21
|
+
<RakeTaskImpl id="rake" />
|
22
|
+
</option>
|
23
|
+
</component>
|
24
|
+
</module>
|
data/.idea/vcs.xml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2021 Jeremiah Church
|
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,29 @@
|
|
1
|
+
# OmniAuth Notion Strategy
|
2
|
+
|
3
|
+
This gem provides a simple way to authenticate to Notion using OmniAuth with OAuth2.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'omniauth-notion'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install omniauth-notion
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write instructions
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'omniauth/strategies/oauth2'
|
4
|
+
|
5
|
+
module OmniAuth
|
6
|
+
module Strategies
|
7
|
+
class Notion < OmniAuth::Strategies::OAuth2
|
8
|
+
# Give your strategy a name.
|
9
|
+
option :name, 'notion'
|
10
|
+
|
11
|
+
# This is where you pass the options you would pass when
|
12
|
+
# initializing your consumer from the OAuth gem.
|
13
|
+
option :client_options,
|
14
|
+
site: 'https://api.notion.com/v1',
|
15
|
+
authorize_url: 'https://api.notion.com/v1/oauth/authorize',
|
16
|
+
token_url: 'https://api.notion.com/v1/oauth/token',
|
17
|
+
connection_opts: { headers: { user_agent: 'Omniauth-notion', accept: 'application/json', content_type: 'application/json' } }
|
18
|
+
|
19
|
+
# These are called after authentication has succeeded. If
|
20
|
+
# possible, you should try to set the UID without making
|
21
|
+
# additional calls (if the user id is returned with the token
|
22
|
+
# or as a URI parameter). This may not be possible with all
|
23
|
+
# providers.
|
24
|
+
uid { raw_info['bot_id'] }
|
25
|
+
|
26
|
+
# https://developers.notion.com/docs/authorization#exchanging-the-grant-for-an-access-token
|
27
|
+
info do
|
28
|
+
{
|
29
|
+
workspace_name: raw_info['workspace_name'],
|
30
|
+
workspace_icon: raw_info['workspace_icon'],
|
31
|
+
bot_id: raw_info['bot_id']
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
extra do
|
36
|
+
{
|
37
|
+
'raw_info' => raw_info
|
38
|
+
}
|
39
|
+
end
|
40
|
+
|
41
|
+
def raw_info
|
42
|
+
@raw_info ||= access_token.post('v1/oauth/token', body: nil.to_json).parsed
|
43
|
+
end
|
44
|
+
|
45
|
+
def callback_url
|
46
|
+
if @authorization_code_from_signed_request
|
47
|
+
''
|
48
|
+
else
|
49
|
+
options[:callback_url] || super
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
# def callback_url
|
54
|
+
# # If redirect_uri is configured in token_params, use that
|
55
|
+
# # value.
|
56
|
+
# token_params.to_hash(symbolize_keys: true)[:redirect_uri] || super
|
57
|
+
# end
|
58
|
+
|
59
|
+
def query_string
|
60
|
+
# This method is called by callback_url, only if redirect_uri
|
61
|
+
# is omitted in token_params.
|
62
|
+
if request.params['code']
|
63
|
+
# If this is a callback, ignore query parameters added by
|
64
|
+
# the provider.
|
65
|
+
''
|
66
|
+
else
|
67
|
+
super
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('../lib', __FILE__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require 'omniauth-notion/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |gem|
|
8
|
+
gem.name = "omniauth-notion"
|
9
|
+
gem.version = Omniauth::Notion::VERSION
|
10
|
+
gem.authors = ["Jeremiah Church"]
|
11
|
+
gem.email = ["jeremiahchurch@gmail.com"]
|
12
|
+
gem.description = %q{OmniAuth strategy for Notion using OAuth2}
|
13
|
+
gem.summary = %q{OmniAuth strategy for Notion using OAuth2}
|
14
|
+
gem.license = 'MIT'
|
15
|
+
gem.homepage = "https://github.com/jeremiahchurch/omniauth-notion"
|
16
|
+
|
17
|
+
gem.files = `git ls-files`.split($/)
|
18
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
19
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
20
|
+
gem.require_paths = ["lib"]
|
21
|
+
|
22
|
+
gem.add_dependency 'omniauth', '~> 1.0'
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-notion
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jeremiah Church
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-05-13 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: '1.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.0'
|
27
|
+
description: OmniAuth strategy for Notion using OAuth2
|
28
|
+
email:
|
29
|
+
- jeremiahchurch@gmail.com
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- ".gitignore"
|
35
|
+
- ".idea/.gitignore"
|
36
|
+
- ".idea/misc.xml"
|
37
|
+
- ".idea/modules.xml"
|
38
|
+
- ".idea/omniauth-notion.iml"
|
39
|
+
- ".idea/vcs.xml"
|
40
|
+
- Gemfile
|
41
|
+
- LICENSE.txt
|
42
|
+
- README.md
|
43
|
+
- Rakefile
|
44
|
+
- lib/omniauth-notion.rb
|
45
|
+
- lib/omniauth-notion/version.rb
|
46
|
+
- omniauth-notion.gemspec
|
47
|
+
homepage: https://github.com/jeremiahchurch/omniauth-notion
|
48
|
+
licenses:
|
49
|
+
- MIT
|
50
|
+
metadata: {}
|
51
|
+
post_install_message:
|
52
|
+
rdoc_options: []
|
53
|
+
require_paths:
|
54
|
+
- lib
|
55
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0'
|
60
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '0'
|
65
|
+
requirements: []
|
66
|
+
rubygems_version: 3.0.3
|
67
|
+
signing_key:
|
68
|
+
specification_version: 4
|
69
|
+
summary: OmniAuth strategy for Notion using OAuth2
|
70
|
+
test_files: []
|