microservices-login 0.7.11
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 +7 -0
- data/CHANGELOG.md +22 -0
- data/LICENSE +5 -0
- data/README.md +2 -0
- data/bin/razorrisk-microservice-login +42 -0
- data/lib/razor_risk/cassini/applications/microservices/login/app.rb +207 -0
- data/lib/razor_risk/cassini/applications/microservices/login/compatability.rb +57 -0
- data/lib/razor_risk/cassini/applications/microservices/login/version.rb +48 -0
- data/lib/razor_risk/cassini/applications/microservices/login.rb +19 -0
- data/lib/razor_risk/cassini/applications/route_verb_adaptors/login/auth_only_login.rb +165 -0
- data/lib/razor_risk/cassini/applications/route_verb_adaptors/login/basic_login.rb +171 -0
- data/lib/razor_risk/cassini/applications/route_verb_adaptors/login/jwt_login.rb +194 -0
- data/lib/razor_risk/cassini/applications/route_verb_adaptors/login/jwt_logout.rb +149 -0
- data/lib/razor_risk/cassini/applications/route_verb_adaptors/login.rb +20 -0
- data/lib/razor_risk/cassini/applications/route_verb_adaptors/utils/call_system_status.rb +85 -0
- data/lib/razor_risk/cassini/applications/route_verb_adaptors/utils/close_session.rb +87 -0
- data/lib/razor_risk/cassini/applications/route_verb_adaptors/utils/open_session.rb +96 -0
- metadata +251 -0
@@ -0,0 +1,171 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
# ######################################################################## #
|
4
|
+
#
|
5
|
+
# Copyright (c) 2019 Razor Risk Technologies Pty Limited. All rights reserved.
|
6
|
+
#
|
7
|
+
# ######################################################################## #
|
8
|
+
|
9
|
+
# ##########################################################
|
10
|
+
# requires
|
11
|
+
|
12
|
+
require 'razor_risk/cassini/applications/rest_framework/verb_handler'
|
13
|
+
require 'razor_risk/cassini/applications/route_verb_adaptors/utils/call_system_status'
|
14
|
+
require 'razor_risk/cassini/authorisation'
|
15
|
+
require 'razor_risk/cassini/header_functions'
|
16
|
+
require 'razor_risk/cassini/util/conversion_util'
|
17
|
+
|
18
|
+
require 'razor_risk/razor/connectivity/entity_connectors/exceptions'
|
19
|
+
|
20
|
+
require 'razor_risk/core/diagnostics/logger'
|
21
|
+
|
22
|
+
require 'pantheios'
|
23
|
+
|
24
|
+
|
25
|
+
# ##########################################################
|
26
|
+
# module
|
27
|
+
|
28
|
+
module RazorRisk
|
29
|
+
module Cassini
|
30
|
+
module Applications
|
31
|
+
module RouteVerbAdaptors
|
32
|
+
module Login
|
33
|
+
|
34
|
+
|
35
|
+
# ##########################################################
|
36
|
+
# BasicLogin
|
37
|
+
|
38
|
+
# Handler for Basic Authentication Login.
|
39
|
+
class BasicLogin < RESTFramework::VerbHandler
|
40
|
+
|
41
|
+
# ##########################################################
|
42
|
+
# includes
|
43
|
+
|
44
|
+
include ::RazorRisk::Cassini::Applications::RouteVerbAdaptors::Utils
|
45
|
+
include ::RazorRisk::Cassini::Authorisation::SecurityModelHelpers
|
46
|
+
include ::RazorRisk::Cassini::Authorisation::HeaderHelpers
|
47
|
+
include ::RazorRisk::Cassini::HeaderFunctions
|
48
|
+
include ::RazorRisk::Cassini::Util::ConversionUtil
|
49
|
+
|
50
|
+
include ::RazorRisk::Razor::Connectivity::EntityConnectors::Exceptions
|
51
|
+
include ::RazorRisk::Razor::Connectivity::Razor3::EntityConnectors
|
52
|
+
|
53
|
+
include ::Pantheios
|
54
|
+
|
55
|
+
include ::RazorRisk::Core::Diagnostics::Logger
|
56
|
+
|
57
|
+
# ##########################################################
|
58
|
+
# constants
|
59
|
+
|
60
|
+
private
|
61
|
+
HTTP_AUTHORIZATION = ::RazorRisk::Cassini::Constants::HTTP_AUTHORIZATION
|
62
|
+
|
63
|
+
public
|
64
|
+
# Supported Content Types.
|
65
|
+
HTTP_ACCEPTS = %w{
|
66
|
+
application/xml
|
67
|
+
application/json
|
68
|
+
text/xml
|
69
|
+
}
|
70
|
+
# Supported HTTP Verb .
|
71
|
+
HTTP_VERB = :post
|
72
|
+
# Supported query parameters.
|
73
|
+
QUERY_PARAMETERS = %w{}
|
74
|
+
# Supported route variables.
|
75
|
+
ROUTE_VARIABLES = %w{}
|
76
|
+
|
77
|
+
|
78
|
+
# ##########################################################
|
79
|
+
# handler
|
80
|
+
|
81
|
+
# Handles a basic authorisation login request.
|
82
|
+
#
|
83
|
+
# @see https://tools.ietf.org/html/rfc7617 RFC-7617 : The 'Basic' HTTP
|
84
|
+
# Authentication Scheme
|
85
|
+
#
|
86
|
+
# @param env [::Hash] The Rack request environment (@see
|
87
|
+
# Rack::Request#env).
|
88
|
+
# @param params [::Hash] Validated query parameters (@see
|
89
|
+
# ValidateQueryParametersHelper#validate_query_parameters)
|
90
|
+
# @param request [::Sinatra::Request] The request to be handled.
|
91
|
+
# @param response [::Sinatra::Response] The response object that will be
|
92
|
+
# used for the HTTP response.
|
93
|
+
def handle env, params, request, response
|
94
|
+
|
95
|
+
trace(
|
96
|
+
ParamNames[ :env, :params, :request, :response ],
|
97
|
+
env, params, request, response
|
98
|
+
)
|
99
|
+
|
100
|
+
auth_scheme = settings.authentication_scheme
|
101
|
+
auth = env[HTTP_AUTHORIZATION]
|
102
|
+
|
103
|
+
unless auth
|
104
|
+
halt 401, make_WWW_auth_header(auth_scheme), 'Missing or invalid authenticate header'
|
105
|
+
end
|
106
|
+
|
107
|
+
username, password, domain = credentials_from_Basic(auth).map do |s|
|
108
|
+
s.empty? ? nil : s unless s.nil?
|
109
|
+
end
|
110
|
+
|
111
|
+
unless username and password
|
112
|
+
halt 401, make_WWW_auth_header(auth_scheme), 'Missing or invalid authenticate header'
|
113
|
+
end
|
114
|
+
|
115
|
+
# All we do here is issue a Razor Request for system-status -
|
116
|
+
# since it's arbitrary, really - and verify that it worked
|
117
|
+
|
118
|
+
options = {
|
119
|
+
auth_test_mode: settings.auth_test_mode,
|
120
|
+
auth_scheme: auth_scheme,
|
121
|
+
razor_requester: settings.razor_requester,
|
122
|
+
message_map: settings.message_map,
|
123
|
+
}
|
124
|
+
|
125
|
+
cr = razor_requester_credentials_options(
|
126
|
+
auth_scheme,
|
127
|
+
[ username, password, domain ],
|
128
|
+
**options
|
129
|
+
)
|
130
|
+
call_system_status(cr, **options)
|
131
|
+
|
132
|
+
status 200
|
133
|
+
|
134
|
+
if request.accept? 'text/plain'
|
135
|
+
|
136
|
+
content_type 'text/plain'
|
137
|
+
''
|
138
|
+
elsif request.accept?('text/xml')
|
139
|
+
|
140
|
+
content_type 'text/xml'
|
141
|
+
%Q{<?xml version="1.0"?><response result="success"/>}
|
142
|
+
elsif request.accept?('application/xml')
|
143
|
+
|
144
|
+
content_type 'application/xml'
|
145
|
+
%Q{<?xml version="1.0"?><response result="success"/>}
|
146
|
+
elsif request.accept? 'application/json'
|
147
|
+
|
148
|
+
content_type 'application/json'
|
149
|
+
'{}'
|
150
|
+
else
|
151
|
+
|
152
|
+
log :violation, 'Invalid accept type'
|
153
|
+
halt 500, {}, 'Oops! Something went wrong!'
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
end # class BasicLogin
|
158
|
+
|
159
|
+
|
160
|
+
# ##########################################################
|
161
|
+
# module
|
162
|
+
|
163
|
+
end # module Login
|
164
|
+
end # module RouteVerbAdaptors
|
165
|
+
end # module Applications
|
166
|
+
end # module Cassini
|
167
|
+
end # module RazorRisk
|
168
|
+
|
169
|
+
# ############################## end of file ############################# #
|
170
|
+
|
171
|
+
|
@@ -0,0 +1,194 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
# ######################################################################## #
|
4
|
+
#
|
5
|
+
# Copyright (c) 2019 Razor Risk Technologies Pty Limited. All rights reserved.
|
6
|
+
#
|
7
|
+
# ######################################################################## #
|
8
|
+
|
9
|
+
# ##########################################################
|
10
|
+
# requires
|
11
|
+
|
12
|
+
require 'razor_risk/cassini/applications/rest_framework/verb_handler'
|
13
|
+
require 'razor_risk/cassini/applications/route_verb_adaptors/utils/open_session'
|
14
|
+
require 'razor_risk/cassini/authorisation'
|
15
|
+
require 'razor_risk/cassini/header_functions'
|
16
|
+
require 'razor_risk/cassini/util/conversion_util'
|
17
|
+
|
18
|
+
require 'razor_risk/razor/connectivity/entity_connectors/exceptions'
|
19
|
+
|
20
|
+
require 'razor_risk/core/diagnostics/logger'
|
21
|
+
|
22
|
+
require 'pantheios'
|
23
|
+
|
24
|
+
|
25
|
+
# ##########################################################
|
26
|
+
# module
|
27
|
+
|
28
|
+
module RazorRisk
|
29
|
+
module Cassini
|
30
|
+
module Applications
|
31
|
+
module RouteVerbAdaptors
|
32
|
+
module Login
|
33
|
+
|
34
|
+
|
35
|
+
# ##########################################################
|
36
|
+
# JWTLogin
|
37
|
+
|
38
|
+
# Handler for JSON Web Token Authentication Login.
|
39
|
+
class JWTLogin < RESTFramework::VerbHandler
|
40
|
+
|
41
|
+
# ##########################################################
|
42
|
+
# includes
|
43
|
+
|
44
|
+
include ::RazorRisk::Cassini::Applications::RouteVerbAdaptors::Utils
|
45
|
+
include ::RazorRisk::Cassini::Authorisation::SecurityModelHelpers
|
46
|
+
include ::RazorRisk::Cassini::Authorisation::HeaderHelpers
|
47
|
+
include ::RazorRisk::Cassini::HeaderFunctions
|
48
|
+
include ::RazorRisk::Cassini::Util::ConversionUtil
|
49
|
+
|
50
|
+
include ::RazorRisk::Razor::Connectivity::EntityConnectors::Exceptions
|
51
|
+
include ::RazorRisk::Razor::Connectivity::Razor3::EntityConnectors
|
52
|
+
|
53
|
+
include ::Pantheios
|
54
|
+
|
55
|
+
include ::RazorRisk::Core::Diagnostics::Logger
|
56
|
+
|
57
|
+
# ##########################################################
|
58
|
+
# constants
|
59
|
+
|
60
|
+
private
|
61
|
+
HTTP_AUTHORIZATION = ::RazorRisk::Cassini::Constants::HTTP_AUTHORIZATION
|
62
|
+
|
63
|
+
public
|
64
|
+
# Supported Content Types.
|
65
|
+
HTTP_ACCEPTS = %w{
|
66
|
+
application/xml
|
67
|
+
application/json
|
68
|
+
text/xml
|
69
|
+
}
|
70
|
+
# Supported HTTP Verb .
|
71
|
+
HTTP_VERB = :post
|
72
|
+
# Supported query parameters.
|
73
|
+
QUERY_PARAMETERS = %w{}
|
74
|
+
# Supported route variables.
|
75
|
+
ROUTE_VARIABLES = %w{}
|
76
|
+
|
77
|
+
|
78
|
+
# ##########################################################
|
79
|
+
# handler
|
80
|
+
|
81
|
+
# Handles a JWT login request which will open a Razor Session and create
|
82
|
+
# a JSON Web Token for that session.
|
83
|
+
#
|
84
|
+
# @see https://tools.ietf.org/html/rfc7519 RFC-7519 : JSON Web Token
|
85
|
+
# (JWT).
|
86
|
+
#
|
87
|
+
# @param env [::Hash] The Rack request environment (@see
|
88
|
+
# Rack::Request#env).
|
89
|
+
# @param params [::Hash] Validated query parameters (@see
|
90
|
+
# ValidateQueryParametersHelper#validate_query_parameters)
|
91
|
+
# @param request [::Sinatra::Request] The request to be handled.
|
92
|
+
# @param response [::Sinatra::Response] The response object that will be
|
93
|
+
# used for the HTTP response.
|
94
|
+
def handle env, params, request, response
|
95
|
+
|
96
|
+
trace(
|
97
|
+
ParamNames[ :env, :params, :request, :response ],
|
98
|
+
env, params, request, response
|
99
|
+
)
|
100
|
+
|
101
|
+
auth_scheme = settings.authentication_scheme
|
102
|
+
auth = env[HTTP_AUTHORIZATION]
|
103
|
+
|
104
|
+
# to serve direct and also as a delegated server, we accept form
|
105
|
+
# params and also accept (delegated) basic authenticate
|
106
|
+
username = params[:username]
|
107
|
+
password = params[:password]
|
108
|
+
domain = params[:domain]
|
109
|
+
|
110
|
+
unless username
|
111
|
+
if auth
|
112
|
+
username, password, domain = credentials_from_Basic(auth).map do |s|
|
113
|
+
s.empty? ? nil : s unless s.nil?
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
unless username && password
|
119
|
+
halt 401, make_WWW_auth_header(auth_scheme), 'Missing or invalid authenticate header'
|
120
|
+
end
|
121
|
+
|
122
|
+
jwt_algo = settings.jwt_encoding_algorithm
|
123
|
+
jwt_sec = @app.secret jwt_algo
|
124
|
+
|
125
|
+
unless jwt_sec
|
126
|
+
log :critical, 'failed to obtain secret for algorithm \'', jwt_algo, '\''
|
127
|
+
error 500, 'Oops! Something went wrong!'
|
128
|
+
end
|
129
|
+
|
130
|
+
cr = razor_requester_credentials_options(
|
131
|
+
:basic,
|
132
|
+
[ username, password, domain ],
|
133
|
+
auth_test_mode: settings.auth_test_mode,
|
134
|
+
)
|
135
|
+
|
136
|
+
options = {
|
137
|
+
auth_test_mode: settings.auth_test_mode,
|
138
|
+
auth_scheme: auth_scheme,
|
139
|
+
razor_requester: settings.razor_requester,
|
140
|
+
message_map: settings.message_map,
|
141
|
+
}
|
142
|
+
|
143
|
+
session_id, user_id, user_name = open_session cr, **options
|
144
|
+
|
145
|
+
jwt = JWT_from_credentials(
|
146
|
+
session_id,
|
147
|
+
user_id,
|
148
|
+
password,
|
149
|
+
jwt_algo,
|
150
|
+
jwt_sec
|
151
|
+
)
|
152
|
+
|
153
|
+
log :informational, "User '#{user_id}' has been logged in"
|
154
|
+
|
155
|
+
status 200
|
156
|
+
|
157
|
+
if request.accept? 'text/plain'
|
158
|
+
|
159
|
+
content_type 'text/plain'
|
160
|
+
return "authorisation-token: #{jwt}"
|
161
|
+
elsif request.accept?('text/xml')
|
162
|
+
|
163
|
+
content_type 'application/xml'
|
164
|
+
return %Q{<?xml version="1.0"?><authorisation-token>#{jwt}</authorisation-token>}
|
165
|
+
elsif request.accept?('application/xml')
|
166
|
+
|
167
|
+
content_type 'application/xml'
|
168
|
+
return %Q{<?xml version="1.0"?><authorisation-token>#{jwt}</authorisation-token>}
|
169
|
+
elsif request.accept? 'application/json'
|
170
|
+
|
171
|
+
content_type 'application/json'
|
172
|
+
return { 'authorisation-token' => jwt }.to_json
|
173
|
+
else
|
174
|
+
|
175
|
+
log :violation, 'Invalid accept type'
|
176
|
+
halt 500, {}, 'Oops! Something went wrong!'
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
end # class JWTLogin
|
181
|
+
|
182
|
+
|
183
|
+
# ##########################################################
|
184
|
+
# module
|
185
|
+
|
186
|
+
end # module Login
|
187
|
+
end # module RouteVerbAdaptors
|
188
|
+
end # module Applications
|
189
|
+
end # module Cassini
|
190
|
+
end # module RazorRisk
|
191
|
+
|
192
|
+
# ############################## end of file ############################# #
|
193
|
+
|
194
|
+
|
@@ -0,0 +1,149 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
# ######################################################################## #
|
4
|
+
#
|
5
|
+
# Copyright (c) 2019 Razor Risk Technologies Pty Limited. All rights reserved.
|
6
|
+
#
|
7
|
+
# ######################################################################## #
|
8
|
+
|
9
|
+
# ##########################################################
|
10
|
+
# requires
|
11
|
+
|
12
|
+
require 'razor_risk/cassini/applications/rest_framework/verb_handler'
|
13
|
+
require 'razor_risk/cassini/applications/route_verb_adaptors/utils/close_session'
|
14
|
+
require 'razor_risk/cassini/authorisation'
|
15
|
+
require 'razor_risk/cassini/header_functions'
|
16
|
+
require 'razor_risk/cassini/util/conversion_util'
|
17
|
+
|
18
|
+
require 'razor_risk/razor/connectivity/entity_connectors/exceptions'
|
19
|
+
|
20
|
+
require 'razor_risk/core/diagnostics/logger'
|
21
|
+
|
22
|
+
require 'pantheios'
|
23
|
+
|
24
|
+
|
25
|
+
# ##########################################################
|
26
|
+
# module
|
27
|
+
|
28
|
+
module RazorRisk
|
29
|
+
module Cassini
|
30
|
+
module Applications
|
31
|
+
module RouteVerbAdaptors
|
32
|
+
module Login
|
33
|
+
|
34
|
+
|
35
|
+
# ##########################################################
|
36
|
+
# JWTLogout
|
37
|
+
|
38
|
+
# Handler for JSON Web Token Authentication Logout.
|
39
|
+
class JWTLogout < RESTFramework::VerbHandler
|
40
|
+
|
41
|
+
# ##########################################################
|
42
|
+
# includes
|
43
|
+
|
44
|
+
include ::RazorRisk::Cassini::Applications::RouteVerbAdaptors::Utils
|
45
|
+
include ::RazorRisk::Cassini::Authorisation::SecurityModelHelpers
|
46
|
+
include ::RazorRisk::Cassini::Authorisation::HeaderHelpers
|
47
|
+
include ::RazorRisk::Cassini::HeaderFunctions
|
48
|
+
include ::RazorRisk::Cassini::Util::ConversionUtil
|
49
|
+
|
50
|
+
include ::RazorRisk::Razor::Connectivity::EntityConnectors::Exceptions
|
51
|
+
include ::RazorRisk::Razor::Connectivity::Razor3::EntityConnectors
|
52
|
+
|
53
|
+
include ::Pantheios
|
54
|
+
|
55
|
+
include ::RazorRisk::Core::Diagnostics::Logger
|
56
|
+
|
57
|
+
|
58
|
+
# ##########################################################
|
59
|
+
# constants
|
60
|
+
|
61
|
+
private
|
62
|
+
HTTP_AUTHORIZATION = ::RazorRisk::Cassini::Constants::HTTP_AUTHORIZATION
|
63
|
+
|
64
|
+
public
|
65
|
+
# Supported Content Types.
|
66
|
+
HTTP_ACCEPTS = %w{
|
67
|
+
application/xml
|
68
|
+
application/json
|
69
|
+
text/xml
|
70
|
+
}
|
71
|
+
# Supported HTTP Verb .
|
72
|
+
HTTP_VERB = :post
|
73
|
+
# Supported query parameters.
|
74
|
+
QUERY_PARAMETERS = %w{}
|
75
|
+
# Supported route variables.
|
76
|
+
ROUTE_VARIABLES = %w{}
|
77
|
+
|
78
|
+
|
79
|
+
# ##########################################################
|
80
|
+
# handler
|
81
|
+
|
82
|
+
# Handles a JWT logout request which will close a Razor Session.
|
83
|
+
#
|
84
|
+
# @param env [::Hash] The Rack request environment (@see
|
85
|
+
# Rack::Request#env).
|
86
|
+
# @param params [::Hash] Validated query parameters (@see
|
87
|
+
# ValidateQueryParametersHelper#validate_query_parameters)
|
88
|
+
# @param request [::Sinatra::Request] The request to be handled.
|
89
|
+
# @param response [::Sinatra::Response] The response object that will be
|
90
|
+
# used for the HTTP response.
|
91
|
+
def handle env, params, request, response
|
92
|
+
|
93
|
+
trace(
|
94
|
+
ParamNames[ :env, :params, :request, :response ],
|
95
|
+
env, params, request, response
|
96
|
+
)
|
97
|
+
|
98
|
+
auth_scheme = settings.authentication_scheme
|
99
|
+
auth = env[HTTP_AUTHORIZATION]
|
100
|
+
|
101
|
+
unless auth
|
102
|
+
halt 401, make_WWW_auth_header(auth_scheme), 'Missing or invalid authenticate header'
|
103
|
+
end
|
104
|
+
|
105
|
+
jwt_algo = settings.jwt_encoding_algorithm
|
106
|
+
jwt_sec = @app.secret jwt_algo
|
107
|
+
|
108
|
+
unless jwt_sec
|
109
|
+
log :critical, 'failed to obtain secret for algorithm \'', jwt_algo, '\''
|
110
|
+
error 500, 'Oops! Something went wrong!'
|
111
|
+
end
|
112
|
+
|
113
|
+
begin
|
114
|
+
session_id, user_id, _ = credentials_from_JWT(auth, jwt_sec)
|
115
|
+
rescue ::JWT::DecodeError
|
116
|
+
halt 401, make_WWW_auth_header(auth_scheme), 'Missing or invalid authenticate header'
|
117
|
+
end
|
118
|
+
|
119
|
+
unless session_id
|
120
|
+
halt 401, make_WWW_auth_header(auth_scheme), 'Missing or invalid authenticate header'
|
121
|
+
end
|
122
|
+
|
123
|
+
log :informational, "User '#{user_id}' has been logged out"
|
124
|
+
|
125
|
+
options = {
|
126
|
+
razor_requester: settings.razor_requester,
|
127
|
+
message_map: settings.message_map,
|
128
|
+
}
|
129
|
+
|
130
|
+
close_session session_id, **options
|
131
|
+
|
132
|
+
status 204
|
133
|
+
end
|
134
|
+
|
135
|
+
end # class JWTLogout
|
136
|
+
|
137
|
+
|
138
|
+
# ##########################################################
|
139
|
+
# module
|
140
|
+
|
141
|
+
end # module Login
|
142
|
+
end # module RouteVerbAdaptors
|
143
|
+
end # module Applications
|
144
|
+
end # module Cassini
|
145
|
+
end # module RazorRisk
|
146
|
+
|
147
|
+
# ############################## end of file ############################# #
|
148
|
+
|
149
|
+
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
# ##########################################################################
|
4
|
+
#
|
5
|
+
# Copyright (c) 2019 Razor Risk Technologies Pty Limited. All rights reserved.
|
6
|
+
#
|
7
|
+
# ##########################################################################
|
8
|
+
|
9
|
+
# ##########################################################
|
10
|
+
# requires
|
11
|
+
|
12
|
+
require 'razor_risk/cassini/applications/route_verb_adaptors/login/auth_only_login'
|
13
|
+
require 'razor_risk/cassini/applications/route_verb_adaptors/login/basic_login'
|
14
|
+
require 'razor_risk/cassini/applications/route_verb_adaptors/login/jwt_login'
|
15
|
+
require 'razor_risk/cassini/applications/route_verb_adaptors/login/jwt_logout'
|
16
|
+
|
17
|
+
|
18
|
+
# ############################## end of file ############################# #
|
19
|
+
|
20
|
+
|
@@ -0,0 +1,85 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
# ##########################################################################
|
4
|
+
#
|
5
|
+
# Copyright (c) 2019 Razor Risk Technologies Pty Limited. All rights reserved.
|
6
|
+
#
|
7
|
+
# ##########################################################################
|
8
|
+
|
9
|
+
# ##########################################################################
|
10
|
+
# requires
|
11
|
+
|
12
|
+
require 'razor_risk/razor/connectivity/entity_connectors/exceptions'
|
13
|
+
require 'razor_risk/razor/connectivity/razor_3/entity_connectors/system_status_connector'
|
14
|
+
|
15
|
+
require 'razor_risk/core/diagnostics/logger'
|
16
|
+
|
17
|
+
require 'pantheios'
|
18
|
+
|
19
|
+
|
20
|
+
# ##########################################################################
|
21
|
+
# module
|
22
|
+
|
23
|
+
module RazorRisk
|
24
|
+
module Cassini
|
25
|
+
module Applications
|
26
|
+
module RouteVerbAdaptors
|
27
|
+
module Utils
|
28
|
+
|
29
|
+
# ##########################################################
|
30
|
+
# inludes
|
31
|
+
|
32
|
+
include ::RazorRisk::Razor::Connectivity::Razor3::EntityConnectors
|
33
|
+
include ::RazorRisk::Razor::Connectivity::Razor3
|
34
|
+
|
35
|
+
include ::Pantheios
|
36
|
+
|
37
|
+
include ::RazorRisk::Core::Diagnostics::Logger
|
38
|
+
|
39
|
+
# ##########################################################
|
40
|
+
# Call System Status
|
41
|
+
|
42
|
+
# Executes as Razor System Status request. Will halt the request if the
|
43
|
+
# provided credentials are invalid with a 403 status.
|
44
|
+
#
|
45
|
+
# @param cr [Hash] A hash of credentials.
|
46
|
+
#
|
47
|
+
# @option options [#send_request] :razor_requester The Razor Requester to be
|
48
|
+
# used to send requests to the Razor application.
|
49
|
+
# @option options [Hash] :message_map The message map used to route razor
|
50
|
+
# requests.
|
51
|
+
def call_system_status cr, **options
|
52
|
+
|
53
|
+
trace ParamNames[ :cr, :options ], cr, options
|
54
|
+
|
55
|
+
ssc = SystemStatusConnector.new(
|
56
|
+
options[:razor_requester],
|
57
|
+
message_map: options[:message_map],
|
58
|
+
credentials: cr
|
59
|
+
)
|
60
|
+
|
61
|
+
begin
|
62
|
+
qr = ssc.get indicate_result_by: :qualified_result
|
63
|
+
rescue RazorRequester::InvalidCredentialsException
|
64
|
+
halt 403, {}, 'Invalid credentials'
|
65
|
+
rescue => x
|
66
|
+
log :violation, "unexpected exception (#{x.class}): '#{x.message}': #{x.backtrace}"
|
67
|
+
raise
|
68
|
+
end
|
69
|
+
|
70
|
+
halt 500, {}, 'Oops! Something went wrong!' unless qr.succeeded?
|
71
|
+
end
|
72
|
+
|
73
|
+
|
74
|
+
# ##########################################################
|
75
|
+
# module
|
76
|
+
|
77
|
+
end # module Utils
|
78
|
+
end # module RouteVerbAdaptors
|
79
|
+
end # module Applications
|
80
|
+
end # module Cassini
|
81
|
+
end # module RazorRisk
|
82
|
+
|
83
|
+
# ############################## end of file ############################# #
|
84
|
+
|
85
|
+
|
@@ -0,0 +1,87 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
# ##########################################################################
|
4
|
+
#
|
5
|
+
# Copyright (c) 2019 Razor Risk Technologies Pty Limited. All rights reserved.
|
6
|
+
#
|
7
|
+
# ##########################################################################
|
8
|
+
|
9
|
+
# ##########################################################################
|
10
|
+
# requires
|
11
|
+
|
12
|
+
require 'razor_risk/razor/connectivity/entity_connectors/exceptions'
|
13
|
+
require 'razor_risk/razor/connectivity/razor_3/entity_connectors/system_status_connector'
|
14
|
+
|
15
|
+
require 'razor_risk/core/diagnostics/logger'
|
16
|
+
|
17
|
+
require 'pantheios'
|
18
|
+
require 'xqsr3/quality/parameter_checking'
|
19
|
+
|
20
|
+
|
21
|
+
# ##########################################################################
|
22
|
+
# module
|
23
|
+
|
24
|
+
module RazorRisk
|
25
|
+
module Cassini
|
26
|
+
module Applications
|
27
|
+
module RouteVerbAdaptors
|
28
|
+
module Utils
|
29
|
+
|
30
|
+
# ##########################################################
|
31
|
+
# inludes
|
32
|
+
|
33
|
+
include ::RazorRisk::Razor::Connectivity::Razor3::EntityConnectors
|
34
|
+
include ::RazorRisk::Razor::Connectivity::Razor3
|
35
|
+
|
36
|
+
include ::RazorRisk::Core::Diagnostics::Logger
|
37
|
+
|
38
|
+
include ::Pantheios
|
39
|
+
include ::Xqsr3::Quality::ParameterChecking
|
40
|
+
|
41
|
+
|
42
|
+
# ##########################################################
|
43
|
+
# Open Session
|
44
|
+
|
45
|
+
# Closes a Razor Session.
|
46
|
+
#
|
47
|
+
# @param session_id [String] The session ID to close.
|
48
|
+
#
|
49
|
+
# @option options [#send_request] :razor_requester The Razor Requester to be
|
50
|
+
# used to send requests to the Razor application.
|
51
|
+
# @option options [Hash] :message_map The message map used to route razor
|
52
|
+
# requests.
|
53
|
+
def close_session session_id, **options
|
54
|
+
|
55
|
+
trace ParamNames[ :session_id, :options ], session_id, options
|
56
|
+
|
57
|
+
check_parameter session_id, 'session_id'
|
58
|
+
|
59
|
+
ec = SessionsConnector.new(
|
60
|
+
options[:razor_requester],
|
61
|
+
message_map: options[:message_map],
|
62
|
+
credentials: { session_id: session_id }
|
63
|
+
)
|
64
|
+
|
65
|
+
begin
|
66
|
+
ec.close_session session_id, indicate_result_by: :qualified_result
|
67
|
+
rescue => x
|
68
|
+
log :violation, "unexpected exception (#{x.class}): '#{x.message}': #{x.backtrace}"
|
69
|
+
raise
|
70
|
+
end
|
71
|
+
|
72
|
+
nil
|
73
|
+
end
|
74
|
+
|
75
|
+
|
76
|
+
# ##########################################################
|
77
|
+
# module
|
78
|
+
|
79
|
+
end # module Utils
|
80
|
+
end # module RouteVerbAdaptors
|
81
|
+
end # module Applications
|
82
|
+
end # module Cassini
|
83
|
+
end # module RazorRisk
|
84
|
+
|
85
|
+
# ############################## end of file ############################# #
|
86
|
+
|
87
|
+
|