ibrain-auth 0.1.4 → 0.1.8

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: a2b1225f8af33476f1430375daa45735726214573801f82565fad70660add87f
4
- data.tar.gz: 22efde3d458f819e088c5e8bb7803aad9f414c76088da3b4dca6b29393f01d15
3
+ metadata.gz: 15dfe6736f21d1568b1c1f3b53403c996c6cc8682eddbf16fca744add91c18a0
4
+ data.tar.gz: 97e95785738830c2517ac34431a85d6dd8d70ca706fcdb8b4dc38e1ebedde3b3
5
5
  SHA512:
6
- metadata.gz: eedd6bfb0ebb31487ae235a96a91c1039962916c4be988d7e7a74325afe96127f40b95e39cb3e6cc64335ec234fbf726e1f35cdac366c8f24117d3f4f8ee2c15
7
- data.tar.gz: 80bd34b348683e2d55ecf3438cd6988c68b4cb7ba6107ae042ea8555cd1b5af4662619c56a2e88c96e9c8d6ed1c19b7f6cbdb773f169c74c47f58376697e7749
6
+ metadata.gz: ee792f65779bdf83b8a681d41295d2df04c5618195c57a0b9410373769504cb407f8d6c7a3c1452fbe95da729b0956659746ec42c876cab886f6769335a0cc4f
7
+ data.tar.gz: 5888a9f6b84227b8189f4157569128ea56a6d5e209f88c123849f3516024cdb6a0e3777a565b7262020290252b4778eb9a5a9e76a340b9ff84689c578e5e9780
@@ -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 SsoSignInMutation < 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
@@ -17,7 +17,7 @@ module Ibrain
17
17
  # for hasura
18
18
  hasura_keys = {
19
19
  'https://hasura.io/jwt/claims': {
20
- 'x-hasura-allowed-roles': [role],
20
+ 'x-hasura-allowed-roles': User.roles.keys,
21
21
  'x-hasura-default-role': role,
22
22
  'x-hasura-user-id': id.to_s
23
23
  }
@@ -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.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.1.3'
14
+ '0.1.7'
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.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-01-05 00:00:00.000000000 Z
11
+ date: 2022-01-14 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