ibrain-auth 0.2.7 → 0.2.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/graphql/ibrain/auth/mutations/sign_up_mutation.rb +1 -1
- data/lib/generators/ibrain/auth/install/templates/config/initializers/ibrain_auth.rb.tt +0 -9
- data/lib/ibrain/auth/version.rb +2 -2
- data/lib/ibrain/auth_configuration.rb +0 -9
- metadata +3 -6
- data/app/graphql/ibrain/auth/mutations/generate_firebase_token_mutation.rb +0 -35
- data/app/graphql/ibrain/auth/types/input/generate_firebase_token_input.rb +0 -13
- data/app/repositories/firebase_repository.rb +0 -41
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9d95d7f9c6c700644ad0e46cf5cabe23f2c41e3892272de755ffda41b13d0c8a
|
4
|
+
data.tar.gz: c75cb28a6655d0320ab3a3a0988817afdf7fda37bc37174ef291cd4d5437d6ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e24aa639225bed4349fd89989fda23cbc80096b5f9b691b3733e45c9c2ba7160eeb7996a0adb27a27a3f5305c4634ce8a77c904e0d814d30830a3754299cbb47
|
7
|
+
data.tar.gz: 1d3d0ac22092f3d436803230a8a9d49b166349a774746112017b6f91bbc976ae77c5b10dbeca7bd687c70ab15550ba2c418584dc00d12cf5fb90ff088e56ffba
|
@@ -16,13 +16,4 @@ Ibrain::Auth.config do |config|
|
|
16
16
|
|
17
17
|
# sign_in graphql input
|
18
18
|
config.sign_up_input = Ibrain::Auth::Types::Input::SignInInput
|
19
|
-
|
20
|
-
# firebase private json path
|
21
|
-
config.firebase_private_key_path = Rails.root.join('static/firebase.json')
|
22
|
-
|
23
|
-
# firebase aud url
|
24
|
-
config.firebase_auth_url = "https://identitytoolkit.googleapis.com/google.identity.identitytoolkit.v1.IdentityToolkit"
|
25
|
-
|
26
|
-
# firebase owner email
|
27
|
-
config.firebase_owner_email = nil
|
28
19
|
end
|
data/lib/ibrain/auth/version.rb
CHANGED
@@ -4,14 +4,14 @@ module Ibrain
|
|
4
4
|
# frozen_string_literal: true
|
5
5
|
|
6
6
|
module Auth
|
7
|
-
VERSION = '0.2.
|
7
|
+
VERSION = '0.2.8'
|
8
8
|
|
9
9
|
def self.ibrain_auth_version
|
10
10
|
VERSION
|
11
11
|
end
|
12
12
|
|
13
13
|
def self.previous_ibrain_auth_minor_version
|
14
|
-
'0.2.
|
14
|
+
'0.2.7'
|
15
15
|
end
|
16
16
|
|
17
17
|
def self.ibrain_auth_gem_version
|
@@ -17,14 +17,5 @@ module Ibrain
|
|
17
17
|
|
18
18
|
# sign_in input
|
19
19
|
preference :sign_in_input, :class, default: Ibrain::Auth::Types::Input::SignInInput
|
20
|
-
|
21
|
-
# firebase private json path
|
22
|
-
preference :firebase_private_key_path, :string, default: Rails.root.join('static/firebase.json')
|
23
|
-
|
24
|
-
# firebase aud url
|
25
|
-
preference :firebase_auth_url, :string, default: "https://identitytoolkit.googleapis.com/google.identity.identitytoolkit.v1.IdentityToolkit"
|
26
|
-
|
27
|
-
# firebase owner email
|
28
|
-
preference :firebase_owner_email, :string, default: nil
|
29
20
|
end
|
30
21
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ibrain-auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tai Nguyen Van
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-10-
|
11
|
+
date: 2022-10-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: devise-encryptable
|
@@ -194,18 +194,15 @@ files:
|
|
194
194
|
- app/controllers/ibrain/auth/sessions_controller.rb
|
195
195
|
- app/controllers/ibrain/auth/unlocks_controller.rb
|
196
196
|
- app/graphql/ibrain/auth/mutations/base_mutation.rb
|
197
|
-
- app/graphql/ibrain/auth/mutations/generate_firebase_token_mutation.rb
|
198
197
|
- app/graphql/ibrain/auth/mutations/sign_in_mutation.rb
|
199
198
|
- app/graphql/ibrain/auth/mutations/sign_out_mutation.rb
|
200
199
|
- app/graphql/ibrain/auth/mutations/sign_up_mutation.rb
|
201
200
|
- app/graphql/ibrain/auth/mutations/social_sign_in_mutation.rb
|
202
|
-
- app/graphql/ibrain/auth/types/input/generate_firebase_token_input.rb
|
203
201
|
- app/graphql/ibrain/auth/types/input/sign_in_input.rb
|
204
202
|
- app/graphql/ibrain/auth/types/input/sign_up_input.rb
|
205
203
|
- app/models/ibrain/auth/user.rb
|
206
204
|
- app/repositories/apple_repository.rb
|
207
205
|
- app/repositories/auth_repository.rb
|
208
|
-
- app/repositories/firebase_repository.rb
|
209
206
|
- app/repositories/twitter_repository.rb
|
210
207
|
- config/initializers/devise.rb
|
211
208
|
- config/locales/en.yml
|
@@ -248,7 +245,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
248
245
|
- !ruby/object:Gem::Version
|
249
246
|
version: '0'
|
250
247
|
requirements: []
|
251
|
-
rubygems_version: 3.
|
248
|
+
rubygems_version: 3.1.6
|
252
249
|
signing_key:
|
253
250
|
specification_version: 4
|
254
251
|
summary: Its Auth is an sso authen gem for Ruby on Rails.
|
@@ -1,35 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Ibrain::Auth::Mutations
|
4
|
-
class GenerateFirebaseTokenMutation < BaseMutation
|
5
|
-
field :result, Boolean, null: true
|
6
|
-
field :token, String, null: true
|
7
|
-
|
8
|
-
argument :attributes, ::Ibrain::Auth::Types::Input::GenerateFirebaseTokenInput, required: true
|
9
|
-
|
10
|
-
def resolve(_args)
|
11
|
-
token = repo.generate_custom_token!
|
12
|
-
|
13
|
-
graphql_returning(token)
|
14
|
-
end
|
15
|
-
|
16
|
-
private
|
17
|
-
|
18
|
-
def normalize_parameters
|
19
|
-
attribute_params.permit(:uid)
|
20
|
-
rescue StandardError
|
21
|
-
ActionController::Parameters.new({})
|
22
|
-
end
|
23
|
-
|
24
|
-
def repo
|
25
|
-
::FirebaseRepository.new(nil, normalize_parameters)
|
26
|
-
end
|
27
|
-
|
28
|
-
def graphql_returning(token)
|
29
|
-
OpenStruct.new(
|
30
|
-
token: token,
|
31
|
-
result: true
|
32
|
-
)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
@@ -1,41 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class FirebaseRepository < Ibrain::BaseRepository
|
4
|
-
def initialize(record, _params)
|
5
|
-
super(nil, record)
|
6
|
-
|
7
|
-
@private_key_json = File.open(Ibrain::Auth::Config.firebase_private_key_path).read
|
8
|
-
@firebase_owner_email = Ibrain::Auth::Config.firebase_owner_email
|
9
|
-
end
|
10
|
-
|
11
|
-
def generate_custom_token!
|
12
|
-
now = Time.now.to_i
|
13
|
-
|
14
|
-
payload = {
|
15
|
-
iss: firebase_owner_email,
|
16
|
-
sub: firebase_owner_email,
|
17
|
-
aud: Ibrain::Auth::Config.firebase_aud_url,
|
18
|
-
iat: now,
|
19
|
-
exp: now + 3600,
|
20
|
-
uid: params[:uid],
|
21
|
-
claims: {}
|
22
|
-
}
|
23
|
-
|
24
|
-
JWT.encode payload, private_key, "RS256"
|
25
|
-
end
|
26
|
-
|
27
|
-
private
|
28
|
-
|
29
|
-
attr_reader :private_key_json, :firebase_owner_email
|
30
|
-
|
31
|
-
def method_name
|
32
|
-
end
|
33
|
-
|
34
|
-
def json_firebase
|
35
|
-
JSON.parse(private_key_json, symbolize_names: true)
|
36
|
-
end
|
37
|
-
|
38
|
-
def private_key
|
39
|
-
OpenSSL::PKey::RSA.new json_firebase[:private_key]
|
40
|
-
end
|
41
|
-
end
|