Our application current using a traditional username/password login to authenticate against our AbpUsers table internally.
We are currently on ABP Framework 5.3.5
I am trying to add a new external oauth authentication, and then attempting to link the external user to an internal user.
context.Services.AddAuthentication()
.AddOAuth("...", options =>
{
options.SignInScheme = IdentityServerConstants.ExternalCookieAuthenticationScheme;
options.ClientId = configuration["...:ClientId"];
options.ClientSecret = configuration["...:ClientSecret"];
options.AuthorizationEndpoint = configuration["...:AuthorizationEndpoint"];
options.CallbackPath = new PathString(configuration["...:CallbackPath"]);
options.TokenEndpoint = configuration["...:TokenEndpoint"];
options.Scope.Add("...");
options.Events = new OAuthEvents()
{
OnCreatingTicket = async context =>
{
var email = context.TokenResponse.Response.RootElement.GetProperty("userinfo").GetProperty("email").ToString();
context.Identity.AddClaim(new Claim(ClaimTypesEnum.UserEmail.GetDescription(), email));
Console.WriteLine(email);
// TODO Link external user to internal, authorize user as internal user
}
};
});
This works, in that the user is set to the external oauth service to login, redirected back to our identity server with the authorization code, and we are able to request a token from their oauth service.
It does not work in that the user just lands on our Identity Server login screen again.
I am also unsure how to link the user to our internal user, and then authorize them as an internal user.
I tried to access the UserManager and SigninManager in the OnTicketCreating event, but I do not seem to have access to them.
user25472340 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.