Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenIdConnect: Manually handle Callback

When configuring the OpenIdConnectOptions.CallbackPathin asp.core, can we provide our own controller/action method to intercept the code being returned from the OIDC server?

I have set up a controller/action method to handle the returned code and in the Startup.cs class, added this option:

.AddOpenIdConnect("oidc", options =>
{
  //other options
  options.CallbackPath = new PathString("/oidc/codehandler");
}

But the action method never gets called even though I see a redirection happening after the user signs in:

http://myserver.com/oidc/codehandler?scope=openid&state=abc123&code=xyz456

What am I doing wrong here?

like image 611
NullReference Avatar asked Feb 08 '26 01:02

NullReference


1 Answers

The CallbackPath is the path where server will redirect after authentication. It's automatically handled by the OIDC middleware itself, We don’t need to create this in our application, the middleware will handle this.

You can use notification events in OIDC OWIN Middlerware which invokes to enable developer control over the authentication process . For example , AuthorizationCodeReceived event can be used to acquire access token using authorization code .

like image 100
Nan Yu Avatar answered Feb 09 '26 14:02

Nan Yu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!