ibrain-auth 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a2b1225f8af33476f1430375daa45735726214573801f82565fad70660add87f
4
- data.tar.gz: 22efde3d458f819e088c5e8bb7803aad9f414c76088da3b4dca6b29393f01d15
3
+ metadata.gz: 30ccc8647d90b04b385f7bb63e24dbdecb1365d6c3db4a4bb187a19b7ab476c3
4
+ data.tar.gz: 25265497ddf2b02cb26b23c1d509749a54947356cb37a7c2179f1cf68efa5639
5
5
  SHA512:
6
- metadata.gz: eedd6bfb0ebb31487ae235a96a91c1039962916c4be988d7e7a74325afe96127f40b95e39cb3e6cc64335ec234fbf726e1f35cdac366c8f24117d3f4f8ee2c15
7
- data.tar.gz: 80bd34b348683e2d55ecf3438cd6988c68b4cb7ba6107ae042ea8555cd1b5af4662619c56a2e88c96e9c8d6ed1c19b7f6cbdb773f169c74c47f58376697e7749
6
+ metadata.gz: 9df833ba495a2139dd9b23f6012ca73ff040e2b4cfcaf7f03efa0dd3be78310bacb1c9e6d88800762c39c053c905bbc9ad4095a3622d8497f2bc867c114b1dc6
7
+ data.tar.gz: ca80d2bb38a7a63247cda64558876af54869a100025261b36eafc8ab93f9888971935fca14400aede6fc9ae8a649bedf6bdf994838ec267c22ca2fde415fd24a
@@ -25,6 +25,8 @@ module Ibrain::Auth::Mutations
25
25
  current_user.jti = jti
26
26
  current_user.save!
27
27
 
28
+ context[:current_user] = current_user
29
+
28
30
  OpenStruct.new(
29
31
  user: user_signed_in? ? current_user : nil,
30
32
  token: current_user.try(:jwt_token),
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ibrain::Auth::Mutations
4
+ class SignInMutation < BaseMutation
5
+ field :user, Types::Objects::UserType, null: true
6
+ field :token, String, null: true
7
+ field :result, Boolean, null: true
8
+
9
+ argument :id_token, String, description: 'Id Token from SSO', required: true
10
+
11
+ def resolve(args)
12
+ # TODO: define logic inside repository
13
+ repo = ::AuthRepository.new(nil, normalize_params(args))
14
+ user = repo.sign_in
15
+
16
+ raise ActionController::InvalidAuthenticityToken, I18n.t('ibrain.errors.account.incorrect') if user.blank?
17
+
18
+ sign_in(resource_name, user)
19
+ @current_user = warden.authenticate!(auth_options)
20
+
21
+ warden.set_user(current_user)
22
+ current_user.jwt_token, jti = auth_headers(request, user)
23
+
24
+ current_user.jti = jti
25
+ current_user.save!
26
+
27
+ context[:current_user] = current_user
28
+
29
+ OpenStruct.new(
30
+ user: user_signed_in? ? current_user : nil,
31
+ token: current_user.try(:jwt_token),
32
+ result: user_signed_in?
33
+ )
34
+ end
35
+
36
+ private
37
+
38
+ def normalize_params(args)
39
+ ActionController::Parameters.new({ auth: args })
40
+ end
41
+
42
+ def auth_options
43
+ { scope: resource_name }
44
+ end
45
+ end
46
+ end
@@ -4,14 +4,14 @@ module Ibrain
4
4
  # frozen_string_literal: true
5
5
 
6
6
  module Auth
7
- VERSION = '0.1.4'
7
+ VERSION = '0.1.5'
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.1.3'
14
+ '0.1.4'
15
15
  end
16
16
 
17
17
  def self.ibrain_auth_gem_version
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.1.4
4
+ version: 0.1.5
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-01-05 00:00:00.000000000 Z
11
+ date: 2022-01-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: devise
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 0.2.0
75
+ version: 0.2.4
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 0.2.0
82
+ version: 0.2.4
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rails
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -132,6 +132,7 @@ files:
132
132
  - app/graphql/ibrain/auth/mutations/base_mutation.rb
133
133
  - app/graphql/ibrain/auth/mutations/sign_in_mutation.rb
134
134
  - app/graphql/ibrain/auth/mutations/sign_out_mutation.rb
135
+ - app/graphql/ibrain/auth/mutations/sso_sign_in_mutation.rb
135
136
  - app/models/ibrain/auth/user.rb
136
137
  - app/repositories/auth_repository.rb
137
138
  - config/initializers/devise.rb