Merge pull request #1041 from nextcloud/authInNC12

Multiple auth headers in NC12
This commit is contained in:
Mario Đanić 2017-05-29 23:50:23 +02:00 committed by GitHub
commit 343b65645c
2 changed files with 9 additions and 4 deletions

View file

@ -178,7 +178,7 @@ dependencies {
compile name: 'touch-image-view' compile name: 'touch-image-view'
compile 'com.android.support:multidex:1.0.1' compile 'com.android.support:multidex:1.0.1'
compile 'com.github.nextcloud:android-library:1.0.18' compile 'com.github.nextcloud:android-library:1.0.20'
compile "com.android.support:support-v4:${supportLibraryVersion}" compile "com.android.support:support-v4:${supportLibraryVersion}"
compile "com.android.support:design:${supportLibraryVersion}" compile "com.android.support:design:${supportLibraryVersion}"
compile 'com.jakewharton:disklrucache:2.0.2' compile 'com.jakewharton:disklrucache:2.0.2'

View file

@ -97,9 +97,14 @@ public class DetectAuthenticationMethodOperation extends RemoteOperation {
// analyze response // analyze response
if (result.getHttpCode() == HttpStatus.SC_UNAUTHORIZED) { if (result.getHttpCode() == HttpStatus.SC_UNAUTHORIZED) {
String authRequest = ((result.getAuthenticateHeader()).trim()).toLowerCase(); ArrayList<String> authHeaders = result.getAuthenticateHeaders();
if (authRequest.startsWith("basic") || authRequest.startsWith("bearer")) {
authMethod = AuthenticationMethod.BASIC_HTTP_AUTH; for (String header : authHeaders) {
// currently we only support basic auth
if (header.toLowerCase().startsWith("basic")) {
authMethod = AuthenticationMethod.BASIC_HTTP_AUTH;
break;
}
} }
// else - fall back to UNKNOWN // else - fall back to UNKNOWN