ibrain-auth 0.1.3 → 0.1.7
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: c9cf0abfef30d7ec1547368f50a91780248bf45fa6bfff1ae916668572ad5b81
|
4
|
+
data.tar.gz: ccaf0348b44548c31e79e13acfe37af66fbbb1cfe92f7635b1e757e60a71c0e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 996d39c80bd0137925cb51c7123e68f3c6a936d21bda905718cc29e324a93aaaf9fd050d1972bcb4bea9bb3dd7d7eae87477312181684d329328ec4ed4bffe5c
|
7
|
+
data.tar.gz: 86a86333374a4a10fbffeaa8f9615a7645dddc915262085f261b719b63256f127635480c1f2d14c8bc656117bb7786e8b9d924fca56a0a3d5bdc5dbc1f74406a
|
@@ -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
|
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.1.
|
7
|
+
VERSION = '0.1.7'
|
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.
|
14
|
+
'0.1.6'
|
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
|
+
version: 0.1.7
|
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-
|
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.
|
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.
|
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
|