Merge "Trace canonicalWebUrl-related issues explicitly with OAuth"
This commit is contained in:
@@ -27,11 +27,14 @@ import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@Singleton
|
||||
class GetOAuthToken implements RestReadView<AccountResource> {
|
||||
|
||||
private static final String BEARER_TYPE = "bearer";
|
||||
private static final Logger log = LoggerFactory.getLogger(GetOAuthToken.class);
|
||||
|
||||
private final Provider<CurrentUser> self;
|
||||
private final OAuthTokenCache tokenCache;
|
||||
@@ -69,9 +72,15 @@ class GetOAuthToken implements RestReadView<AccountResource> {
|
||||
}
|
||||
|
||||
private static String getHostName(String canonicalWebUrl) {
|
||||
if (canonicalWebUrl == null) {
|
||||
log.error("No canonicalWebUrl defined in gerrit.config, OAuth may not work properly");
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
return new URI(canonicalWebUrl).getHost();
|
||||
} catch (URISyntaxException e) {
|
||||
log.error("Invalid canonicalWebUrl '" + canonicalWebUrl + "'", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user