Let's say I have to integrate with a legacy enterprise system which maintains users. Assume this enterprise system provides a C# SDK with two methods as follows:
Authentication:
sdk.Authenticate("Region", "Username", "Password")
Note that Region
is an additional parameter selected by the user at login. So I need to be able to read this custom parameter in addition to the user credentials too. (Yes login would be interactive).
Profile Retrieval:
sdk.GetProfile(UserId)
I want to use IdentityServer to generate tokens in the usual manner but use these two methods to implement custom authentication and profile retrieval.
I can see that extending the IProfileService
I should be able to integrate profile retrieval and population of custom claims. However I see the following multiple extensibility points in the docs but not sure what the best way would be;
Quick Start UI's Account Controller
's Login(LoginInputModel model, string button)
method: I should be able to place the sdk.Authenticate("Region", "Username", "Password")
logic here and just call _signInManager.SignInAsync to sign in the user. But it does not feel as if I'm directly extending IdentityServer4 to add support for another custom authentication provider.
IExtensionGrantValidator:
This answer and IdentityServer Docs explain a way to do a custom grant which I should be able to use to call sdk.Authenticate("Region", "Username", "Password")
. But this would mean I'd be using a custom grant type. I need to be able to support existing grant types such as Hybrid. I see support for custom parameters via context
parameter in the ValidateAsync(ExtensionGrantValidationContext context)
method
IResourceOwnerPasswordValidator:
This IdentityServer doc explains how to implement a custom password validator for the Resource Owner flow. But I need to be able to support existing grant types such as Hybrid. I see support for custom parameters via context
parameter in the ValidateAsync(ResourceOwnerPasswordValidationContext context)
method
External Authenticators:
This IdentityServer doc explains how to add external authenticators. But I see no .AddCustom
method for non-standard authenticators. I only see support for popular authenticators such as Google.
What am I missing?
I chose to go with the first option mentioned in the question which is: Quick Start UI's Account Controller
's Login(LoginInputModel model, string button)
method