@@ -137,7 +137,9 @@ private AuthTokenProcessorAction.Response handleImpl(
137
137
String samlResponseBase64 ,
138
138
String samlRequestId ,
139
139
String acsEndpoint ,
140
- Saml2Settings saml2Settings
140
+ Saml2Settings saml2Settings ,
141
+ String requestPath // the parameter will be removed in the future as soon as we will read of legacy paths aka
142
+ // /_opendistro/_security/...
141
143
) {
142
144
if (token_log .isDebugEnabled ()) {
143
145
try {
@@ -156,7 +158,7 @@ private AuthTokenProcessorAction.Response handleImpl(
156
158
final SamlResponse samlResponse = new SamlResponse (saml2Settings , acsEndpoint , samlResponseBase64 );
157
159
158
160
if (!samlResponse .isValid (samlRequestId )) {
159
- log .warn ("Error while validating SAML response in /_opendistro/_security/api/authtoken" );
161
+ log .warn ("Error while validating SAML response in {}" , requestPath );
160
162
return null ;
161
163
}
162
164
@@ -178,17 +180,14 @@ private Optional<SecurityResponse> handleLowLevel(RestRequest restRequest) throw
178
180
179
181
if (restRequest .getMediaType () != XContentType .JSON ) {
180
182
throw new OpenSearchSecurityException (
181
- "/_opendistro/_security/api/authtoken expects content with type application/json" ,
183
+ restRequest . path () + " expects content with type application/json" ,
182
184
RestStatus .UNSUPPORTED_MEDIA_TYPE
183
185
);
184
186
185
187
}
186
188
187
189
if (restRequest .method () != Method .POST ) {
188
- throw new OpenSearchSecurityException (
189
- "/_opendistro/_security/api/authtoken expects POST requests" ,
190
- RestStatus .METHOD_NOT_ALLOWED
191
- );
190
+ throw new OpenSearchSecurityException (restRequest .path () + " expects POST requests" , RestStatus .METHOD_NOT_ALLOWED );
192
191
}
193
192
194
193
Saml2Settings saml2Settings = this .saml2SettingsProvider .getCached ();
@@ -218,7 +217,13 @@ private Optional<SecurityResponse> handleLowLevel(RestRequest restRequest) throw
218
217
acsEndpoint = getAbsoluteAcsEndpoint (((ObjectNode ) jsonRoot ).get ("acsEndpoint" ).textValue ());
219
218
}
220
219
221
- AuthTokenProcessorAction .Response responseBody = this .handleImpl (samlResponseBase64 , samlRequestId , acsEndpoint , saml2Settings );
220
+ AuthTokenProcessorAction .Response responseBody = this .handleImpl (
221
+ samlResponseBase64 ,
222
+ samlRequestId ,
223
+ acsEndpoint ,
224
+ saml2Settings ,
225
+ restRequest .path ()
226
+ );
222
227
223
228
if (responseBody == null ) {
224
229
return Optional .empty ();
@@ -228,7 +233,7 @@ private Optional<SecurityResponse> handleLowLevel(RestRequest restRequest) throw
228
233
229
234
return Optional .of (new SecurityResponse (HttpStatus .SC_OK , null , responseBodyString , XContentType .JSON .mediaType ()));
230
235
} catch (JsonProcessingException e ) {
231
- log .warn ("Error while parsing JSON for /_opendistro/_security/api/authtoken" , e );
236
+ log .warn ("Error while parsing JSON for {}" , restRequest . path () , e );
232
237
return Optional .of (new SecurityResponse (HttpStatus .SC_BAD_REQUEST , "JSON could not be parsed" ));
233
238
}
234
239
}
0 commit comments