fbase_auth 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/workflows/build.yml +29 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.rubocop.yml +31 -0
- data/CHANGELOG.md +5 -0
- data/Dockerfile +8 -0
- data/Gemfile +12 -0
- data/Gemfile.lock +87 -0
- data/LICENSE.txt +21 -0
- data/Makefile +23 -0
- data/README.md +67 -0
- data/Rakefile +12 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/docker-compose.yml +7 -0
- data/fbase_auth.gemspec +37 -0
- data/lib/fbase_auth/action/base.rb +13 -0
- data/lib/fbase_auth/action/confirm_email_verification.rb +17 -0
- data/lib/fbase_auth/action/confirm_password_reset.rb +21 -0
- data/lib/fbase_auth/action/delete_account.rb +17 -0
- data/lib/fbase_auth/action/send_email_verification.rb +20 -0
- data/lib/fbase_auth/action/send_password_reset_email.rb +20 -0
- data/lib/fbase_auth/action/sign_in_with_password.rb +22 -0
- data/lib/fbase_auth/action/sign_up.rb +22 -0
- data/lib/fbase_auth/action/verify_password_reset_code.rb +17 -0
- data/lib/fbase_auth/client.rb +3 -0
- data/lib/fbase_auth/client_decorator.rb +16 -0
- data/lib/fbase_auth/config.rb +15 -0
- data/lib/fbase_auth/helper.rb +15 -0
- data/lib/fbase_auth/request.rb +13 -0
- data/lib/fbase_auth/version.rb +5 -0
- data/lib/fbase_auth.rb +25 -0
- metadata +78 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: f855c0c74114e8f6d0166a84007475ec645abbc35288da30cbdca1c9d01cb4d7
|
4
|
+
data.tar.gz: c77012d34ab623ca225f7f00fed54f1391283a2ba6a0461af931e33fa7a658e1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 783f520abded32bd221ebab8e8de2b16c2b2563e8af55fb4f11c6a84198e342ef2745e760241f11e6f71eeb92ce9d7c16526725b23c65b808dbbd2c570acd10b
|
7
|
+
data.tar.gz: 7befc8fd0f1f0c48c3c20d4ae72817a349c1abf68636b3c682d53612d3a9551cdbdb6f1543dd12807c6ca958755e4ac3d5c932fa8a565611165094b5512d659c
|
@@ -0,0 +1,29 @@
|
|
1
|
+
name: build
|
2
|
+
on:
|
3
|
+
pull_request:
|
4
|
+
branches:
|
5
|
+
- '*'
|
6
|
+
push:
|
7
|
+
branches:
|
8
|
+
- '*'
|
9
|
+
|
10
|
+
jobs:
|
11
|
+
build:
|
12
|
+
runs-on: ubuntu-latest
|
13
|
+
|
14
|
+
steps:
|
15
|
+
- uses: actions/checkout@v1
|
16
|
+
|
17
|
+
- name: Set up Ruby 2.6.6
|
18
|
+
uses: actions/setup-ruby@v1
|
19
|
+
with:
|
20
|
+
ruby-version: 2.6.6
|
21
|
+
|
22
|
+
- name: build
|
23
|
+
run: |
|
24
|
+
gem install bundler
|
25
|
+
bin/setup
|
26
|
+
- name: rspec
|
27
|
+
run: bundle exec rspec
|
28
|
+
- name: Run Rubocop
|
29
|
+
run: bundle exec rubocop
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 2.6.6
|
3
|
+
|
4
|
+
Style/StringLiterals:
|
5
|
+
Enabled: true
|
6
|
+
EnforcedStyle: double_quotes
|
7
|
+
|
8
|
+
Style/StringLiteralsInInterpolation:
|
9
|
+
Enabled: true
|
10
|
+
EnforcedStyle: double_quotes
|
11
|
+
|
12
|
+
Style/MethodDefParentheses:
|
13
|
+
Enabled: false
|
14
|
+
|
15
|
+
Style/Documentation:
|
16
|
+
Enabled: false
|
17
|
+
|
18
|
+
Style/ClassAndModuleChildren:
|
19
|
+
Enabled: false
|
20
|
+
|
21
|
+
Lint/MissingSuper:
|
22
|
+
Enabled: false
|
23
|
+
|
24
|
+
Metrics/BlockLength:
|
25
|
+
Exclude:
|
26
|
+
- 'Rakefile'
|
27
|
+
- '**/*.rake'
|
28
|
+
- 'spec/**/*.rb'
|
29
|
+
|
30
|
+
Layout/LineLength:
|
31
|
+
Max: 120
|
data/CHANGELOG.md
ADDED
data/Dockerfile
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
# Specify your gem's dependencies in fbase_auth.gemspec
|
6
|
+
gemspec
|
7
|
+
|
8
|
+
gem "http", "~> 4.4.1"
|
9
|
+
gem "rake", "~> 13.0.3"
|
10
|
+
gem "rspec", "~> 3.10.0"
|
11
|
+
gem "rubocop", "~> 1.10.0"
|
12
|
+
gem "webmock", "~> 3.12"
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
fbase_auth (0.1.3)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
addressable (2.7.0)
|
10
|
+
public_suffix (>= 2.0.2, < 5.0)
|
11
|
+
ast (2.4.2)
|
12
|
+
crack (0.4.5)
|
13
|
+
rexml
|
14
|
+
diff-lcs (1.4.4)
|
15
|
+
domain_name (0.5.20190701)
|
16
|
+
unf (>= 0.0.5, < 1.0.0)
|
17
|
+
ffi (1.15.0)
|
18
|
+
ffi-compiler (1.0.1)
|
19
|
+
ffi (>= 1.0.0)
|
20
|
+
rake
|
21
|
+
hashdiff (1.0.1)
|
22
|
+
http (4.4.1)
|
23
|
+
addressable (~> 2.3)
|
24
|
+
http-cookie (~> 1.0)
|
25
|
+
http-form_data (~> 2.2)
|
26
|
+
http-parser (~> 1.2.0)
|
27
|
+
http-cookie (1.0.3)
|
28
|
+
domain_name (~> 0.5)
|
29
|
+
http-form_data (2.3.0)
|
30
|
+
http-parser (1.2.3)
|
31
|
+
ffi-compiler (>= 1.0, < 2.0)
|
32
|
+
parallel (1.20.1)
|
33
|
+
parser (3.0.0.0)
|
34
|
+
ast (~> 2.4.1)
|
35
|
+
public_suffix (4.0.6)
|
36
|
+
rainbow (3.0.0)
|
37
|
+
rake (13.0.3)
|
38
|
+
regexp_parser (2.1.1)
|
39
|
+
rexml (3.2.4)
|
40
|
+
rspec (3.10.0)
|
41
|
+
rspec-core (~> 3.10.0)
|
42
|
+
rspec-expectations (~> 3.10.0)
|
43
|
+
rspec-mocks (~> 3.10.0)
|
44
|
+
rspec-core (3.10.1)
|
45
|
+
rspec-support (~> 3.10.0)
|
46
|
+
rspec-expectations (3.10.1)
|
47
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
48
|
+
rspec-support (~> 3.10.0)
|
49
|
+
rspec-mocks (3.10.2)
|
50
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
51
|
+
rspec-support (~> 3.10.0)
|
52
|
+
rspec-support (3.10.2)
|
53
|
+
rubocop (1.10.0)
|
54
|
+
parallel (~> 1.10)
|
55
|
+
parser (>= 3.0.0.0)
|
56
|
+
rainbow (>= 2.2.2, < 4.0)
|
57
|
+
regexp_parser (>= 1.8, < 3.0)
|
58
|
+
rexml
|
59
|
+
rubocop-ast (>= 1.2.0, < 2.0)
|
60
|
+
ruby-progressbar (~> 1.7)
|
61
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
62
|
+
rubocop-ast (1.4.1)
|
63
|
+
parser (>= 2.7.1.5)
|
64
|
+
ruby-progressbar (1.11.0)
|
65
|
+
unf (0.1.4)
|
66
|
+
unf_ext
|
67
|
+
unf_ext (0.0.7.7)
|
68
|
+
unicode-display_width (2.0.0)
|
69
|
+
webmock (3.12.2)
|
70
|
+
addressable (>= 2.3.6)
|
71
|
+
crack (>= 0.3.2)
|
72
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
73
|
+
|
74
|
+
PLATFORMS
|
75
|
+
ruby
|
76
|
+
x86_64-linux
|
77
|
+
|
78
|
+
DEPENDENCIES
|
79
|
+
fbase_auth!
|
80
|
+
http (~> 4.4.1)
|
81
|
+
rake (~> 13.0.3)
|
82
|
+
rspec (~> 3.10.0)
|
83
|
+
rubocop (~> 1.10.0)
|
84
|
+
webmock (~> 3.12)
|
85
|
+
|
86
|
+
BUNDLED WITH
|
87
|
+
2.2.14
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2021 Scotto
|
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/Makefile
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
docker:
|
2
|
+
@docker-compose build
|
3
|
+
@docker-compose up -d
|
4
|
+
|
5
|
+
start:
|
6
|
+
@docker-compose start
|
7
|
+
|
8
|
+
restart:
|
9
|
+
@docker-compose restart
|
10
|
+
|
11
|
+
stop:
|
12
|
+
@docker-compose stop
|
13
|
+
|
14
|
+
clean:
|
15
|
+
@docker-compose down
|
16
|
+
@docker system prune --volumes --force
|
17
|
+
@rm -rf tmp/* || sudo rm -rf tmp/*
|
18
|
+
|
19
|
+
bash:
|
20
|
+
@docker-compose exec fbase_auth bash
|
21
|
+
|
22
|
+
logs:
|
23
|
+
@docker-compose logs -f --tail=0 app
|
data/README.md
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
# FbaseAuth ![build](https://github.com/joaoscotto/fbase_auth/workflows/build/badge.svg?event=push) [![Gem version](https://img.shields.io/gem/v/fbase_auth.svg)](https://rubygems.org/gems/fbase_auth)
|
2
|
+
|
3
|
+
FbaseAuth is a Ruby wrapper for [Firebase Authentication](https://firebase.google.com/docs/auth).
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'fbase_auth'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle install
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install fbase_auth
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
|
24
|
+
### Configuration example:
|
25
|
+
|
26
|
+
```ruby
|
27
|
+
|
28
|
+
FbaseAuth.configure do |config|
|
29
|
+
config.api_key = 'example'
|
30
|
+
config.return_secure_token = false #(default is true)
|
31
|
+
end
|
32
|
+
```
|
33
|
+
### Usage examples:
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
FbaseAuth::Client.sign_up(email:, password: '')
|
37
|
+
FbaseAuth::Client.sign_in_with_password(email:, password: '')
|
38
|
+
FbaseAuth::Client.send_email_verification(id_token: '')
|
39
|
+
FbaseAuth::Client.confirm_email_verification(oob_code: '')
|
40
|
+
FbaseAuth::Client.send_password_reset_email(email: '')
|
41
|
+
FbaseAuth::Client.verify_password_reset_code(oob_code: '')
|
42
|
+
FbaseAuth::Client.confirm_password_reset(oob_code: '', new_password: '')
|
43
|
+
FbaseAuth::Client.delete_account(id_token: '')
|
44
|
+
```
|
45
|
+
|
46
|
+
## Development
|
47
|
+
|
48
|
+
### Build and start Docker
|
49
|
+
|
50
|
+
```bash
|
51
|
+
make docker
|
52
|
+
make bash
|
53
|
+
```
|
54
|
+
|
55
|
+
See the [Makefile](/Makefile) for more commands.
|
56
|
+
|
57
|
+
### Publish a new version
|
58
|
+
|
59
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
60
|
+
|
61
|
+
## Contributing
|
62
|
+
|
63
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/joaoscotto/fbase_auth.
|
64
|
+
|
65
|
+
## License
|
66
|
+
|
67
|
+
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,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "bundler/setup"
|
5
|
+
require "fbase_auth"
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require "irb"
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/docker-compose.yml
ADDED
data/fbase_auth.gemspec
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/fbase_auth/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "fbase_auth"
|
7
|
+
spec.version = FbaseAuth::VERSION
|
8
|
+
spec.authors = ["Scotto"]
|
9
|
+
spec.email = ["joao.scotto@gmail.com"]
|
10
|
+
|
11
|
+
spec.summary = "Firebase Authentication for Ruby"
|
12
|
+
spec.description = "Firebase Authentication for Ruby"
|
13
|
+
spec.homepage = "https://github.com/joaoscotto/fbase_auth"
|
14
|
+
spec.license = "MIT"
|
15
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.6.6")
|
16
|
+
|
17
|
+
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
18
|
+
|
19
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
20
|
+
spec.metadata["source_code_uri"] = "https://github.com/joaoscotto/fbase_auth"
|
21
|
+
spec.metadata["changelog_uri"] = "https://github.com/joaoscotto/fbase_auth/blob/master/CHANGELOG.md"
|
22
|
+
|
23
|
+
# Specify which files should be added to the gem when it is released.
|
24
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
25
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
26
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
|
27
|
+
end
|
28
|
+
spec.bindir = "exe"
|
29
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
30
|
+
spec.require_paths = ["lib"]
|
31
|
+
|
32
|
+
# Uncomment to register a new dependency of your gem
|
33
|
+
# spec.add_dependency "example-gem", "~> 1.0"
|
34
|
+
|
35
|
+
# For more information and examples about making a new gem, checkout our
|
36
|
+
# guide at: https://bundler.io/guides/creating_gem.html
|
37
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module FbaseAuth::Action
|
4
|
+
class ConfirmEmailVerification < Base
|
5
|
+
PATH = "update"
|
6
|
+
|
7
|
+
def initialize oob_code:
|
8
|
+
@oob_code = oob_code
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def payload
|
14
|
+
{ oobCode: @oob_code }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module FbaseAuth::Action
|
4
|
+
class ConfirmPasswordReset < Base
|
5
|
+
PATH = "resetPassword"
|
6
|
+
|
7
|
+
def initialize oob_code:, new_password:
|
8
|
+
@oob_code = oob_code
|
9
|
+
@new_password = new_password
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def payload
|
15
|
+
{
|
16
|
+
oobCode: @oob_code,
|
17
|
+
newPassword: @new_password
|
18
|
+
}
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module FbaseAuth::Action
|
4
|
+
class SendEmailVerification < Base
|
5
|
+
PATH = "sendOobCode"
|
6
|
+
|
7
|
+
def initialize id_token:
|
8
|
+
@id_token = id_token
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def payload
|
14
|
+
{
|
15
|
+
idToken: @id_token,
|
16
|
+
requestType: "VERIFY_EMAIL"
|
17
|
+
}
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module FbaseAuth::Action
|
4
|
+
class SendPasswordResetEmail < Base
|
5
|
+
PATH = "sendOobCode"
|
6
|
+
|
7
|
+
def initialize email:
|
8
|
+
@email = email
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def payload
|
14
|
+
{
|
15
|
+
email: @email,
|
16
|
+
requestType: "PASSWORD_RESET"
|
17
|
+
}
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module FbaseAuth::Action
|
4
|
+
class SignInWithPassword < Base
|
5
|
+
PATH = "signInWithPassword"
|
6
|
+
|
7
|
+
def initialize email:, password:
|
8
|
+
@email = email
|
9
|
+
@password = password
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def payload
|
15
|
+
{
|
16
|
+
email: @email,
|
17
|
+
password: @password,
|
18
|
+
return_secure_token: true
|
19
|
+
}
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module FbaseAuth::Action
|
4
|
+
class SignUp < Base
|
5
|
+
PATH = "signUp"
|
6
|
+
|
7
|
+
def initialize email:, password:
|
8
|
+
@email = email
|
9
|
+
@password = password
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def payload
|
15
|
+
{
|
16
|
+
email: @email,
|
17
|
+
password: @password,
|
18
|
+
return_secure_token: true
|
19
|
+
}
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module FbaseAuth::Action
|
4
|
+
class VerifyPasswordResetCode < Base
|
5
|
+
PATH = "resetPassword"
|
6
|
+
|
7
|
+
def initialize oob_code:
|
8
|
+
@oob_code = oob_code
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def payload
|
14
|
+
{ oobCode: @oob_code }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module FbaseAuth::ClientDecorator
|
4
|
+
def self.apply
|
5
|
+
FbaseAuth::Helper.action_classes.each do |klass|
|
6
|
+
klass_name = FbaseAuth::Helper.camelize klass
|
7
|
+
|
8
|
+
FbaseAuth::Client.define_singleton_method klass do |**args|
|
9
|
+
Object
|
10
|
+
.const_get("FbaseAuth::Action::#{klass_name}")
|
11
|
+
.new(**args)
|
12
|
+
.call
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module FbaseAuth
|
4
|
+
class Config
|
5
|
+
HOST = "https://identitytoolkit.googleapis.com/v1/accounts:"
|
6
|
+
attr_reader :host
|
7
|
+
attr_accessor :api_key, :return_secure_token
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
@api_key = ""
|
11
|
+
@host = HOST
|
12
|
+
@return_secure_token = true
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module FbaseAuth::Helper
|
4
|
+
def self.camelize str
|
5
|
+
str.split("_").map(&:capitalize).join
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.action_classes
|
9
|
+
Dir
|
10
|
+
.entries("#{File.dirname(__FILE__)}/action/")
|
11
|
+
.map { |file| file.gsub(".rb", "") if file.include?(".rb") }
|
12
|
+
.tap { |file| file.delete("base") }
|
13
|
+
.compact
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module FbaseAuth::Request
|
4
|
+
def self.post path, payload
|
5
|
+
url = "#{FbaseAuth.config.host}#{path}?key=#{FbaseAuth.config.api_key}"
|
6
|
+
response = HTTP.post url, json: payload
|
7
|
+
|
8
|
+
{
|
9
|
+
code: response.code,
|
10
|
+
body: JSON.parse(response.to_s)
|
11
|
+
}
|
12
|
+
end
|
13
|
+
end
|
data/lib/fbase_auth.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "http"
|
4
|
+
require "fbase_auth/version"
|
5
|
+
require "fbase_auth/config"
|
6
|
+
require "fbase_auth/client"
|
7
|
+
require "fbase_auth/client_decorator"
|
8
|
+
require "fbase_auth/helper"
|
9
|
+
require "fbase_auth/request"
|
10
|
+
Dir["#{File.dirname(__FILE__)}/fbase_auth/action/*.rb"].sort.each { |file| require file }
|
11
|
+
|
12
|
+
module FbaseAuth
|
13
|
+
class << self
|
14
|
+
attr_writer :config
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.config
|
18
|
+
@config ||= Config.new
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.configure
|
22
|
+
yield config
|
23
|
+
FbaseAuth::ClientDecorator.apply
|
24
|
+
end
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fbase_auth
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Scotto
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-04-04 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Firebase Authentication for Ruby
|
14
|
+
email:
|
15
|
+
- joao.scotto@gmail.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- ".github/workflows/build.yml"
|
21
|
+
- ".gitignore"
|
22
|
+
- ".rspec"
|
23
|
+
- ".rubocop.yml"
|
24
|
+
- CHANGELOG.md
|
25
|
+
- Dockerfile
|
26
|
+
- Gemfile
|
27
|
+
- Gemfile.lock
|
28
|
+
- LICENSE.txt
|
29
|
+
- Makefile
|
30
|
+
- README.md
|
31
|
+
- Rakefile
|
32
|
+
- bin/console
|
33
|
+
- bin/setup
|
34
|
+
- docker-compose.yml
|
35
|
+
- fbase_auth.gemspec
|
36
|
+
- lib/fbase_auth.rb
|
37
|
+
- lib/fbase_auth/action/base.rb
|
38
|
+
- lib/fbase_auth/action/confirm_email_verification.rb
|
39
|
+
- lib/fbase_auth/action/confirm_password_reset.rb
|
40
|
+
- lib/fbase_auth/action/delete_account.rb
|
41
|
+
- lib/fbase_auth/action/send_email_verification.rb
|
42
|
+
- lib/fbase_auth/action/send_password_reset_email.rb
|
43
|
+
- lib/fbase_auth/action/sign_in_with_password.rb
|
44
|
+
- lib/fbase_auth/action/sign_up.rb
|
45
|
+
- lib/fbase_auth/action/verify_password_reset_code.rb
|
46
|
+
- lib/fbase_auth/client.rb
|
47
|
+
- lib/fbase_auth/client_decorator.rb
|
48
|
+
- lib/fbase_auth/config.rb
|
49
|
+
- lib/fbase_auth/helper.rb
|
50
|
+
- lib/fbase_auth/request.rb
|
51
|
+
- lib/fbase_auth/version.rb
|
52
|
+
homepage: https://github.com/joaoscotto/fbase_auth
|
53
|
+
licenses:
|
54
|
+
- MIT
|
55
|
+
metadata:
|
56
|
+
homepage_uri: https://github.com/joaoscotto/fbase_auth
|
57
|
+
source_code_uri: https://github.com/joaoscotto/fbase_auth
|
58
|
+
changelog_uri: https://github.com/joaoscotto/fbase_auth/blob/master/CHANGELOG.md
|
59
|
+
post_install_message:
|
60
|
+
rdoc_options: []
|
61
|
+
require_paths:
|
62
|
+
- lib
|
63
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: 2.6.6
|
68
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
requirements: []
|
74
|
+
rubygems_version: 3.0.9
|
75
|
+
signing_key:
|
76
|
+
specification_version: 4
|
77
|
+
summary: Firebase Authentication for Ruby
|
78
|
+
test_files: []
|