omniauth-accountkit 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/CHANGELOG.md +14 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +33 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/omniauth/accountkit.rb +2 -0
- data/lib/omniauth/accountkit/version.rb +5 -0
- data/lib/omniauth/strategies/accountkit.rb +67 -0
- data/omniauth-accountkit.gemspec +28 -0
- metadata +104 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 729952e3ae99280af3be2a3073f8478a0e232a5230c6cd25c90a0da186c6bd8a
|
4
|
+
data.tar.gz: d40be7f7a8d3869bfd55a6bd6aed81c9313516894bc8cfdefd98d3a28ffbe048
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f09835169f789fa6656599297a877f35043411dcd815c24d888dd72f9c3b9c82fea45cda75ec8143cf4287231adb5056ddf0214dbaa96337dc154573ca6ec2d2
|
7
|
+
data.tar.gz: 3863a4c23a8c61450cbd257bdbd98fd6ea503c4e42d220610588237bb82fc14f8edfb4eeb80219e6be7d381ed86bb7545e51f08f7286ce019f8f2cbeab169c67
|
data/.gitignore
ADDED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# Changelog
|
2
|
+
All notable changes to this project will be documented in this file.
|
3
|
+
|
4
|
+
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
5
|
+
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
6
|
+
|
7
|
+
## [Unreleased]
|
8
|
+
|
9
|
+
## 0.1.0 - 2018-05-28
|
10
|
+
### Added
|
11
|
+
|
12
|
+
* Import the project with initial implementation.
|
13
|
+
|
14
|
+
[Unreleased]: https://github.com/polydice/omniauth-accountkit/compare/v0.1.0...HEAD
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 Richard Lee
|
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,33 @@
|
|
1
|
+
# OmniAuth AccountKit
|
2
|
+
|
3
|
+
Account Kit strategy for OmniAuth.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'omniauth-accountkit'
|
11
|
+
```
|
12
|
+
|
13
|
+
Then `bundle install`
|
14
|
+
|
15
|
+
## Usage
|
16
|
+
|
17
|
+
Read the OmniAuth docs for detailed instructions: https://github.com/intridea/omniauth.
|
18
|
+
|
19
|
+
Here's an example:
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
Rails.application.config.middleware.use OmniAuth::Builder do
|
23
|
+
provider :accountkit, ENV["ACCOUNTKIT_APP_ID"], ENV["ACCOUNTKIT_APP_SECRET"]
|
24
|
+
end
|
25
|
+
```
|
26
|
+
|
27
|
+
## Contributing
|
28
|
+
|
29
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/polydice/omniauth-accountkit.
|
30
|
+
|
31
|
+
## License
|
32
|
+
|
33
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "omniauth/accountkit"
|
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
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'omniauth-oauth2'
|
2
|
+
|
3
|
+
module OmniAuth
|
4
|
+
module Strategies
|
5
|
+
class AccountKit < OmniAuth::Strategies::OAuth2
|
6
|
+
option :client_options, {
|
7
|
+
site: "https://graph.accountkit.com/v1.2/",
|
8
|
+
authorize_url: "https://www.accountkit.com/v1.2/basic/dialog/sms_login/",
|
9
|
+
token_url: "access_token",
|
10
|
+
token_method: :get
|
11
|
+
}
|
12
|
+
|
13
|
+
option :provider_ignores_state, true
|
14
|
+
|
15
|
+
def request_phase
|
16
|
+
redirect client.auth_code.authorize_url({app_id: options.client_id, redirect: callback_url}.merge(authorize_params))
|
17
|
+
end
|
18
|
+
|
19
|
+
def authorize_params
|
20
|
+
super.tap do |params|
|
21
|
+
params["fbAppEventsEnabled"] = true
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def token_params
|
26
|
+
super.tap do |params|
|
27
|
+
params["access_token"] = app_access_token
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
uid { raw_info['id'] }
|
32
|
+
|
33
|
+
info do
|
34
|
+
{
|
35
|
+
number: raw_info['phone']['number'],
|
36
|
+
country_prefix: raw_info['phone']['country_prefix'],
|
37
|
+
national_number: raw_info['phone']['national_number']
|
38
|
+
}
|
39
|
+
end
|
40
|
+
|
41
|
+
extra do
|
42
|
+
{
|
43
|
+
raw_info: raw_info
|
44
|
+
}
|
45
|
+
end
|
46
|
+
|
47
|
+
def raw_info
|
48
|
+
@raw_info ||= access_token.get('/me').parsed
|
49
|
+
end
|
50
|
+
|
51
|
+
protected
|
52
|
+
|
53
|
+
def build_access_token
|
54
|
+
verifier = request.params["code"]
|
55
|
+
client.auth_code.get_token(verifier, token_params.to_hash(symbolize_keys: true), deep_symbolize(options.auth_token_params))
|
56
|
+
end
|
57
|
+
|
58
|
+
private
|
59
|
+
|
60
|
+
def app_access_token
|
61
|
+
"AA|#{options.client_id}|#{options.client_secret}"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
OmniAuth.config.add_camelization 'accountkit', 'AccountKit'
|
@@ -0,0 +1,28 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "omniauth/accountkit/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "omniauth-accountkit"
|
8
|
+
spec.version = Omniauth::Accountkit::VERSION
|
9
|
+
spec.authors = ["Richard Lee"]
|
10
|
+
spec.email = ["rl@polydice.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{OmniAuth strategy for AccountKit}
|
13
|
+
spec.description = spec.summary
|
14
|
+
spec.homepage = "https://github.com/polydice/omniauth-accountkit"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
|
+
f.match(%r{^(test|spec|features)/})
|
19
|
+
end
|
20
|
+
spec.bindir = "exe"
|
21
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
+
spec.require_paths = ["lib"]
|
23
|
+
|
24
|
+
spec.add_runtime_dependency 'omniauth-oauth2', '>= 1.4.0', '< 2.0'
|
25
|
+
|
26
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
27
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-accountkit
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Richard Lee
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-05-28 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.4.0
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '2.0'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 1.4.0
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '2.0'
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: bundler
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '1.16'
|
40
|
+
type: :development
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '1.16'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rake
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '10.0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '10.0'
|
61
|
+
description: OmniAuth strategy for AccountKit
|
62
|
+
email:
|
63
|
+
- rl@polydice.com
|
64
|
+
executables: []
|
65
|
+
extensions: []
|
66
|
+
extra_rdoc_files: []
|
67
|
+
files:
|
68
|
+
- ".gitignore"
|
69
|
+
- CHANGELOG.md
|
70
|
+
- Gemfile
|
71
|
+
- LICENSE.txt
|
72
|
+
- README.md
|
73
|
+
- Rakefile
|
74
|
+
- bin/console
|
75
|
+
- bin/setup
|
76
|
+
- lib/omniauth/accountkit.rb
|
77
|
+
- lib/omniauth/accountkit/version.rb
|
78
|
+
- lib/omniauth/strategies/accountkit.rb
|
79
|
+
- omniauth-accountkit.gemspec
|
80
|
+
homepage: https://github.com/polydice/omniauth-accountkit
|
81
|
+
licenses:
|
82
|
+
- MIT
|
83
|
+
metadata: {}
|
84
|
+
post_install_message:
|
85
|
+
rdoc_options: []
|
86
|
+
require_paths:
|
87
|
+
- lib
|
88
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
requirements: []
|
99
|
+
rubyforge_project:
|
100
|
+
rubygems_version: 2.7.3
|
101
|
+
signing_key:
|
102
|
+
specification_version: 4
|
103
|
+
summary: OmniAuth strategy for AccountKit
|
104
|
+
test_files: []
|