Class: RazorRisk::Cassini::Applications::RouteVerbAdaptors::Login::JWTLogout
- Inherits:
-
RESTFramework::VerbHandler
- Object
- RESTFramework::VerbHandler
- RazorRisk::Cassini::Applications::RouteVerbAdaptors::Login::JWTLogout
- Includes:
- Pantheios, Utils, RazorRisk::Cassini::Authorisation::HeaderHelpers, RazorRisk::Cassini::Authorisation::SecurityModelHelpers, HeaderFunctions, Util::ConversionUtil, RazorRisk::Core::Diagnostics::Logger, Razor::Connectivity::EntityConnectors::Exceptions, Razor::Connectivity::Razor3::EntityConnectors
- Defined in:
- lib/razor_risk/cassini/applications/route_verb_adaptors/login/jwt_logout.rb
Overview
Handler for JSON Web Token Authentication Logout.
Constant Summary collapse
- HTTP_ACCEPTS =
Supported Content Types.
%w{ application/xml application/json text/xml }
- HTTP_VERB =
Supported HTTP Verb .
:post
- QUERY_PARAMETERS =
Supported query parameters.
%w{}
- ROUTE_VARIABLES =
Supported route variables.
%w{}
Instance Method Summary collapse
-
#handle(env, params, request, response) ⇒ Object
Handles a JWT logout request which will close a Razor Session.
Methods included from Utils
#call_system_status, #close_session, #open_session
Instance Method Details
#handle(env, params, request, response) ⇒ Object
Handles a JWT logout request which will close a Razor Session.
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/razor_risk/cassini/applications/route_verb_adaptors/login/jwt_logout.rb', line 91 def handle env, params, request, response trace( ParamNames[ :env, :params, :request, :response ], env, params, request, response ) auth_scheme = settings.authentication_scheme auth = env[HTTP_AUTHORIZATION] unless auth halt 401, make_WWW_auth_header(auth_scheme), 'Missing or invalid authenticate header' end jwt_algo = settings.jwt_encoding_algorithm jwt_sec = @app.secret jwt_algo unless jwt_sec log :critical, 'failed to obtain secret for algorithm \'', jwt_algo, '\'' error 500, 'Oops! Something went wrong!' end begin session_id, user_id, _ = credentials_from_JWT(auth, jwt_sec) rescue ::JWT::DecodeError halt 401, make_WWW_auth_header(auth_scheme), 'Missing or invalid authenticate header' end unless session_id halt 401, make_WWW_auth_header(auth_scheme), 'Missing or invalid authenticate header' end log :informational, "User '#{user_id}' has been logged out" = { razor_requester: settings.razor_requester, message_map: settings., } close_session session_id, ** status 204 end |