made webfinger endpoint search by email address, then by username
parent
5aa5cc1a10
commit
348ff7ee17
|
@ -111,16 +111,18 @@ public class DiscoveryEndpoint {
|
||||||
if (resourceUri != null
|
if (resourceUri != null
|
||||||
&& resourceUri.getScheme() != null
|
&& resourceUri.getScheme() != null
|
||||||
&& resourceUri.getScheme().equals("acct")) {
|
&& resourceUri.getScheme().equals("acct")) {
|
||||||
// acct: URI
|
// acct: URI (email address format)
|
||||||
|
|
||||||
UserInfo user = userService.getByUsername(resourceUri.getUserInfo()); // first part is the username
|
// check on email addresses first
|
||||||
|
UserInfo user = userService.getByEmailAddress(resourceUri.getUserInfo() + "@" + resourceUri.getHost());
|
||||||
|
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
logger.info("User not found: " + resource);
|
// user wasn't found, see if the local part of the username matches, plus our issuer host
|
||||||
model.addAttribute(HttpCodeView.CODE, HttpStatus.NOT_FOUND);
|
|
||||||
return HttpCodeView.VIEWNAME;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
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();
|
UriComponents issuerComponents = UriComponentsBuilder.fromHttpUrl(config.getIssuer()).build();
|
||||||
if (!Strings.nullToEmpty(issuerComponents.getHost())
|
if (!Strings.nullToEmpty(issuerComponents.getHost())
|
||||||
.equals(Strings.nullToEmpty(resourceUri.getHost()))) {
|
.equals(Strings.nullToEmpty(resourceUri.getHost()))) {
|
||||||
|
@ -129,6 +131,16 @@ public class DiscoveryEndpoint {
|
||||||
return HttpCodeView.VIEWNAME;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
logger.info("Unknown URI format: " + resource);
|
logger.info("Unknown URI format: " + resource);
|
||||||
|
@ -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("resource", resource);
|
||||||
model.addAttribute("issuer", config.getIssuer());
|
model.addAttribute("issuer", config.getIssuer());
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue