-
Notifications
You must be signed in to change notification settings - Fork 24.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make Authn and Audit take a HTTP interface when dealing with Rest req…
…uests (#94990) AuthN and Audit are NOT going to have access to the Rest interface anymore, because the AuthenticationService is going to be invoked before the RestRequest is built. This refactoring makes the AuthenticationService and the AuditTrail take as parameters HTTP-related request interfaces.
- Loading branch information
1 parent
e24a572
commit a8d5723
Showing
22 changed files
with
244 additions
and
198 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
server/src/main/java/org/elasticsearch/http/HttpPreRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
package org.elasticsearch.http; | ||
|
||
import org.elasticsearch.rest.RestRequest; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
/** | ||
* A slim interface for precursors to HTTP requests, which doesn't expose access to the request's body, | ||
* because it's not available yet. | ||
*/ | ||
public interface HttpPreRequest { | ||
|
||
/** | ||
* Returns the HTTP method used in the HTTP request. | ||
* | ||
* @return the {@link RestRequest.Method} used in the request | ||
* @throws IllegalArgumentException if the HTTP method is invalid | ||
*/ | ||
RestRequest.Method method(); | ||
|
||
/** | ||
* The uri with the query string. | ||
*/ | ||
String uri(); | ||
|
||
/** | ||
* Get all of the headers and values associated with the HTTP headers. | ||
* Modifications of this map are not supported. | ||
*/ | ||
Map<String, List<String>> getHeaders(); | ||
|
||
default String header(String name) { | ||
List<String> values = getHeaders().get(name); | ||
if (values != null && values.isEmpty() == false) { | ||
return values.get(0); | ||
} | ||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.