Consider the following scenario:
On MVC 5 (or higher), you have enabled 3rd party authentication (e.g. Facebook, Google).
As part of the authentication process, we want to perform an additional operation with the 3rd party authentication provider -- e.g. Facebook check if the logging-in user has liked a particular page, or if the user's email address is pre-approved/white-listed somewhere.
The cycle of events seems like it should be: 1. Authenticate user via external service (e.g. get user-id/email and 3rd party uniqueID) 2. Use 3rd party uniqueID (e.g. Facebook Id #) to perform queries to get some information about the user 3. If the user matches some criteria, sign-in user; if not return to login screen
To me, it seems like there should be a method we can override in the the authentication process like this that would do the trick:
(This hypothetical example of what I'm looking for covers checking the property of the user in the normal login-in cycle -- we'll get to doing additional 3rd party querying in a second).
override Boolean BeforeReturnSignedInUser(AppUser user){
if (whitelistedUsers.Email.Contains(user.email)){
return true;
}
else {
return false;
}
Similarly, it seems like there should be a way to access the 3rd party accessToken fairly easily to perform additional logic against the 3rd party social media graph, but it seems like, according to this, not: MVC 5 Web API with Facebook access token to RegisterExternal without need of Cookie
(On the other hand, this is more encouraging: How to access Facebook private information by using ASP.NET Identity (OWIN)? but still requires adding a lot of artifacts for what should be a pretty simple operation)
In any event, neither of these examples seem clean -- seems like adding a lot of complexity to do an additional check that is all of 5 lines of code!