Class GitHubVerifiedEmailLookup
java.lang.Object
com.irurueta.authserver.authorization.infrastructure.github.GitHubVerifiedEmailLookup
- All Implemented Interfaces:
VerifiedEmailLookup
VerifiedEmailLookup over GitHub's GET /user/emails, called through the client generated from
apis/github/rest-server/github-api-v1.yaml. The email of GitHub's profile is whatever the user chose
to show and is not verified, so the address is read from that endpoint, which flags each address as primary and
verified.
The base URI of the API is the user-info URI of the registration without its trailing /user (by default
https://api.github.com), so a GitHub Enterprise registration, or the fake provider of the tests, is called
where it is. Every failure (GitHub unreachable, an error status, an unreadable body, a user-info URI of another
shape) means "no verified address", which refuses the sign-in; it is logged without the token or anything of the
user.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final GitHubEmailMapperPicks the verified primary address.(package private) static final StringPath of the user endpoint below the base URI of GitHub's API.private final GitHubUsersApiFactoryBuilds the generated client of each call. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbasePathOf(String userInfoUri) Derives the base URI of the API from the user-info URI.verifiedPrimaryEmail(String userInfoUri, String accessToken) Finds the verified primary address.
-
Field Details
-
USER_PATH
Path of the user endpoint below the base URI of GitHub's API.- See Also:
-
usersApiFactory
Builds the generated client of each call. -
emailMapper
Picks the verified primary address.
-
-
Constructor Details
-
GitHubVerifiedEmailLookup
public GitHubVerifiedEmailLookup()
-
-
Method Details
-
verifiedPrimaryEmail
Finds the verified primary address.- Specified by:
verifiedPrimaryEmailin interfaceVerifiedEmailLookup- Parameters:
userInfoUri- URI of GitHub's user endpoint, as the registration configures it.accessToken- GitHub access token of the user.- Returns:
- the address, or an empty optional when there is none or GitHub cannot tell.
-
basePathOf
Derives the base URI of the API from the user-info URI.- Parameters:
userInfoUri- URI of the user endpoint, possiblynull.- Returns:
- the URI without its trailing
/user(and slashes), or an empty optional when it does not end so.
-