made webfinger endpoint search by email address, then by username
parent
5aa5cc1a10
commit
348ff7ee17
|
@ -111,25 +111,37 @@ public class DiscoveryEndpoint {
|
|||
if (resourceUri != null
|
||||
&& resourceUri.getScheme() != null
|
||||
&& resourceUri.getScheme().equals("acct")) {
|
||||
// acct: URI
|
||||
|
||||
UserInfo user = userService.getByUsername(resourceUri.getUserInfo()); // first part is the username
|
||||
// acct: URI (email address format)
|
||||
|
||||
// check on email addresses first
|
||||
UserInfo user = userService.getByEmailAddress(resourceUri.getUserInfo() + "@" + resourceUri.getHost());
|
||||
|
||||
if (user == null) {
|
||||
logger.info("User not found: " + resource);
|
||||
model.addAttribute(HttpCodeView.CODE, HttpStatus.NOT_FOUND);
|
||||
return HttpCodeView.VIEWNAME;
|
||||
// user wasn't found, see if the local part of the username matches, plus our issuer host
|
||||
|
||||
user = userService.getByUsername(resourceUri.getUserInfo()); // first part is the username
|
||||
|
||||
if (user != null) {
|
||||
// username matched, check the host component
|
||||
UriComponents issuerComponents = UriComponentsBuilder.fromHttpUrl(config.getIssuer()).build();
|
||||
if (!Strings.nullToEmpty(issuerComponents.getHost())
|
||||
.equals(Strings.nullToEmpty(resourceUri.getHost()))) {
|
||||
logger.info("Host mismatch, expected " + issuerComponents.getHost() + " got " + resourceUri.getHost());
|
||||
model.addAttribute(HttpCodeView.CODE, HttpStatus.NOT_FOUND);
|
||||
return HttpCodeView.VIEWNAME;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
// if the user's still null, punt and say we didn't find them
|
||||
|
||||
logger.info("User not found: " + resource);
|
||||
model.addAttribute(HttpCodeView.CODE, HttpStatus.NOT_FOUND);
|
||||
return HttpCodeView.VIEWNAME;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
UriComponents issuerComponents = UriComponentsBuilder.fromHttpUrl(config.getIssuer()).build();
|
||||
if (!Strings.nullToEmpty(issuerComponents.getHost())
|
||||
.equals(Strings.nullToEmpty(resourceUri.getHost()))) {
|
||||
logger.info("Host mismatch, expected " + issuerComponents.getHost() + " got " + resourceUri.getHost());
|
||||
model.addAttribute(HttpCodeView.CODE, HttpStatus.NOT_FOUND);
|
||||
return HttpCodeView.VIEWNAME;
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
logger.info("Unknown URI format: " + resource);
|
||||
model.addAttribute(HttpCodeView.CODE, HttpStatus.NOT_FOUND);
|
||||
|
@ -137,7 +149,7 @@ public class DiscoveryEndpoint {
|
|||
}
|
||||
}
|
||||
|
||||
// if we got here, then we're good
|
||||
// if we got here, then we're good, return ourselves
|
||||
model.addAttribute("resource", resource);
|
||||
model.addAttribute("issuer", config.getIssuer());
|
||||
|
||||
|
|
Loading…
Reference in New Issue