firebase_auth_latest 0.1.1 → 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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5eac8ec4584b9cc3efdd599b3bae8d8dd39041cea2470361b94f48da4703c84f
|
4
|
+
data.tar.gz: f5392c0f3edf5a3a5d1622c4058beb833e49978613efd9a1009767712484cd80
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e4118977ac4f87db2a3fe6cb839d55bfbf73221ef6e5bc05125ab65a6f3ae94d1a548a5730b3aa260d81d98086cd2bf0248d97e26dfe72808aba3454228287e
|
7
|
+
data.tar.gz: 400754af8555b9446e358629d0fd43ff4628a9deab20864f124a69db43d26b1203589a4218170651a342eede9fa23761a952a8840eb0c3566dcf23903d9bc89d
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'rails/railtie'
|
2
|
+
|
3
|
+
module FirebaseAuth
|
4
|
+
class Railtie < Rails::Railtie
|
5
|
+
railtie_name :firebase_auth
|
6
|
+
|
7
|
+
rake_tasks do
|
8
|
+
load "tasks/firebase_auth_tasks.rake"
|
9
|
+
end
|
10
|
+
|
11
|
+
generators do
|
12
|
+
require "generators/firebase_auth/model_generator"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
module FirebaseAuth
|
4
|
+
module Generators
|
5
|
+
class ModelGenerator < Rails::Generators::NamedBase
|
6
|
+
source_root File.expand_path('templates', __dir__)
|
7
|
+
|
8
|
+
def create_model_file
|
9
|
+
template 'model.rb.tt', File.join('app/models', class_path, "#{file_name}.rb")
|
10
|
+
end
|
11
|
+
|
12
|
+
def create_migration_file
|
13
|
+
generate 'migration', "Create#{class_name.pluralize} email:string user_id:string"
|
14
|
+
end
|
15
|
+
|
16
|
+
def inject_authenticate_method
|
17
|
+
inject_into_class 'app/controllers/application_controller.rb', ApplicationController do
|
18
|
+
<<-RUBY
|
19
|
+
|
20
|
+
before_action :authenticate_#{file_name}
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def authenticate_#{file_name}
|
25
|
+
id_token = request.headers['Authorization']&.split(' ')&.last
|
26
|
+
if id_token
|
27
|
+
decoded_token = FirebaseAuthService::FirebaseAuthService.new(Rails.application.credentials.dig(:firebase, :project_id)).verify_id_token(id_token)
|
28
|
+
if decoded_token
|
29
|
+
@current_#{file_name} = #{class_name}.find_by(email: decoded_token['email'])
|
30
|
+
end
|
31
|
+
end
|
32
|
+
render json: { error: 'Unauthorized' }, status: :unauthorized unless @current_#{file_name}
|
33
|
+
end
|
34
|
+
RUBY
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: firebase_auth_latest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Taha Ali Irfan
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rails
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '5.0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '5.0'
|
55
69
|
description: A gem for integrating Firebase Authentication into your Rails application..
|
56
70
|
email:
|
57
71
|
- tahairfan1993@gmail.com
|
@@ -63,8 +77,11 @@ files:
|
|
63
77
|
- README.md
|
64
78
|
- lib/firebase_auth.rb
|
65
79
|
- lib/firebase_auth/firebase_auth.rb
|
80
|
+
- lib/firebase_auth/railtie.rb
|
66
81
|
- lib/firebase_auth/user.rb
|
67
82
|
- lib/firebase_auth/version.rb
|
83
|
+
- lib/generators/firebase_auth/model_generator.rb
|
84
|
+
- lib/generators/templates/model.rb.tt
|
68
85
|
homepage: https://github.com/tahairfan13/firebase_auth
|
69
86
|
licenses:
|
70
87
|
- MIT
|