Merge pull request #4644 from nextcloud/detectAuth

Allow broader check on CheckAuth
This commit is contained in:
Tobias Kaminsky 2019-10-09 21:06:00 +02:00 committed by GitHub
commit 07d0abe87e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -97,12 +97,12 @@ public class DetectAuthenticationMethodOperation extends RemoteOperation {
}
// analyze response
if (result.getHttpCode() == HttpStatus.SC_UNAUTHORIZED) {
if (result.getHttpCode() == HttpStatus.SC_UNAUTHORIZED || result.getHttpCode() == HttpStatus.SC_FORBIDDEN) {
ArrayList<String> authHeaders = result.getAuthenticateHeaders();
for (String header : authHeaders) {
// currently we only support basic auth
if (header.toLowerCase(Locale.ROOT).startsWith("basic")) {
if (header.toLowerCase(Locale.ROOT).contains("basic")) {
authMethod = AuthenticationMethod.BASIC_HTTP_AUTH;
break;
}
@ -129,7 +129,7 @@ public class DetectAuthenticationMethodOperation extends RemoteOperation {
}
private String authenticationMethodToString(AuthenticationMethod value) {
switch (value){
switch (value) {
case NONE:
return "NONE";
case BASIC_HTTP_AUTH: