@Override public void onServerInfoResolved(App app, ServerInfo serverInfo) { this.authorizeUrl = parseUrl(this.authorizeUrl,serverInfo); this.tokenUrl = parseUrl(this.tokenUrl,serverInfo); this.tokenInfoUrl = parseUrl(this.tokenInfoUrl,serverInfo); this.userInfoUrl = parseUrl(this.userInfoUrl,serverInfo); this.publicKeyUrl = parseUrl(this.publicKeyUrl,serverInfo); this.logoutUrl = parseUrl(this.logoutUrl,serverInfo); }
if(!server.isEnabled() && !oc.isEnabled()) { security.setEnabled(false); return; log.info("OAuth2 enabled : client id '{}', authorizeUrl '{}'", oc.getClientId(), oc.getAuthorizeUrl()); oauth2.setClientId(oc.getClientId()); oauth2.setClientSecret(oc.getClientSecret()); oauth2.setAuthorizeUrl(oc.getAuthorizeUrl()); oauth2.setPublicKeyUrl(oc.getPublicKeyUrl()); oauth2.setTokenInfoUrl(oc.getTokenInfoUrl()); oauth2.setTokenUrl(oc.getTokenUrl()); oauth2.setUserInfoUrl(oc.getUserInfoUrl()); SecurityConsts.USER, SecurityConsts.USER, oc.getAuthorizeUrl(), oc.getTokenUrl(), SwaggerConstants.IMPLICIT, null); SecurityConsts.CLIENT, SecurityConsts.CLIENT, oc.getAuthorizeUrl(), oc.getTokenUrl(), SwaggerConstants.APPLICATION, null);
protected void autoConfigureOAuth2(OAuth2Server server, DefaultOAuth2Config oc) { verifier.update(server, oc); if(Strings.isEmpty(oc.getClientId()) && Strings.isEmpty(oc.getTokenInfoUrl())) { oc.setClientId(OAuth2Client.INTERNAL_CLIENT_ID); oc.setServerUrl(server.getUrl()); } }
protected String parseUrl(String url,ServerInfo serverInfo){ if(!needParse(url)){ return url; } URI uri = URI.create(Strings.replace(serverInfo.getServerUrl(), " ", "%20")); String resolvedUrl = Urls.resolveUrlExpr(url, uri); if(needParse(resolvedUrl)){ return serverInfo.getServerUrl()+Paths.prefixWithSlash(resolvedUrl); } return resolvedUrl; }