mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
perf(core): check for Credential= before reading the SigV4 scope segment (#8528)
* perf(core): check for Credential= before reading the SigV4 scope segment
This commit is contained in:
1 parent
e340c552b0
commit
0d2ea3a9eb
2 files changed
+9
-9
No files matched your search
@@ -105,13 +105,13 @@ public class RegionResolver {
|
||||
if (authorizationHeader == null || authorizationHeader.isEmpty()) {
|
||||
return defaultRegion;
|
||||
}
|
||||
if (!SigV4CredentialScope.hasCredential(authorizationHeader)) {
|
||||
return defaultRegion;
|
||||
}
|
||||
String region = SigV4CredentialScope.segment(authorizationHeader, SigV4CredentialScope.Segment.THIRD);
|
||||
if (region != null) {
|
||||
return withoutPseudoRegion(region);
|
||||
}
|
||||
if (!SigV4CredentialScope.hasCredential(authorizationHeader)) {
|
||||
return defaultRegion;
|
||||
}
|
||||
Matcher matcher = CREDENTIAL_REGION_PATTERN.matcher(authorizationHeader);
|
||||
return matcher.find() ? withoutPseudoRegion(matcher.group(1)) : defaultRegion;
|
||||
}
|
||||
@@ -198,13 +198,13 @@ public class RegionResolver {
|
||||
if (authorizationHeader == null || authorizationHeader.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
if (!SigV4CredentialScope.hasCredential(authorizationHeader)) {
|
||||
return null;
|
||||
}
|
||||
String region = SigV4CredentialScope.segment(authorizationHeader, SigV4CredentialScope.Segment.THIRD);
|
||||
if (region != null) {
|
||||
return withoutPseudoRegion(region);
|
||||
}
|
||||
if (!SigV4CredentialScope.hasCredential(authorizationHeader)) {
|
||||
return null;
|
||||
}
|
||||
Matcher matcher = CREDENTIAL_REGION_PATTERN.matcher(authorizationHeader);
|
||||
return matcher.find() ? withoutPseudoRegion(matcher.group(1)) : null;
|
||||
}
|
||||
|
||||
@@ -103,13 +103,13 @@ public final class SigV4CredentialScope {
|
||||
if (authorization == null) {
|
||||
return Optional.empty();
|
||||
}
|
||||
if (!hasCredential(authorization)) {
|
||||
return Optional.empty();
|
||||
}
|
||||
String service = segment(authorization, Segment.SERVICE);
|
||||
if (service != null) {
|
||||
return Optional.of(service.toLowerCase(Locale.ROOT));
|
||||
}
|
||||
if (!hasCredential(authorization)) {
|
||||
return Optional.empty();
|
||||
}
|
||||
Matcher matcher = SERVICE_PATTERN.matcher(authorization);
|
||||
if (matcher.find()) {
|
||||
return Optional.of(matcher.group(1).toLowerCase(Locale.ROOT));
|
||||
|
||||
Reference in new issue
Block a user