File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed
opengrok-web/src/main/java/org/opengrok/web/api/v1/filter Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -80,6 +80,8 @@ public class IncomingFilter implements ContainerRequestFilter {
80
80
81
81
static final String BEARER = "Bearer " ; // Authorization header value prefix
82
82
83
+ private Set <String > tokens ;
84
+
83
85
@ PostConstruct
84
86
public void init () {
85
87
try {
@@ -90,6 +92,9 @@ public void init() {
90
92
} catch (IOException e ) {
91
93
logger .log (Level .SEVERE , "Could not get localhost addresses" , e );
92
94
}
95
+
96
+ // Cache the tokens to avoid locking.
97
+ tokens = RuntimeEnvironment .getInstance ().getAuthenticationTokens ();
93
98
}
94
99
95
100
@ Override
@@ -104,7 +109,7 @@ public void filter(final ContainerRequestContext context) {
104
109
String authHeaderValue = request .getHeader (HttpHeaders .AUTHORIZATION );
105
110
if (authHeaderValue != null && authHeaderValue .startsWith (BEARER )) {
106
111
String tokenValue = authHeaderValue .substring (BEARER .length ());
107
- if (RuntimeEnvironment . getInstance (). getAuthenticationTokens () .contains (tokenValue )) {
112
+ if (tokens .contains (tokenValue )) {
108
113
logger .log (Level .FINEST , "allowing request to {0} based on authentication header token" , path );
109
114
return ;
110
115
}
You can’t perform that action at this time.
0 commit comments