openiddict / openiddict-samples

.NET samples for OpenIddict

Home Page:https://documentation.openiddict.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Wildcard Redirect or Post Logout Redirect Uris

kdudley21 opened this issue · comments

Confirm you've already contributed to this project or that you sponsor it

  • I confirm I'm a sponsor or a contributor

Version

5.1.0

Question

Good morning !

I know this may come as an odd questions but does openiddict support wildcard Redirect or Post Logout Redirect Uris ?
This way I could set up a client and regardless of the passed redirect or postlogout redirect uri as long as it matched the wildcard pattern it would honor it.

As always thanks a ton for your help!

Hey @kdudley21 😃

Support is reserved to sponsors and contributors who still have a valid subscription active. For more information on how to sponsor the project on GitHub, visit https://github.com/sponsors/kevinchalet.

Hope to see you back on board!

Sorry about that I didnt realize it had been so long since I contributed !

No worries 😄
Thanks for re-sponsoring the project!

I know this may come as an odd questions but does openiddict support wildcard Redirect or Post Logout Redirect Uris ?
This way I could set up a client and regardless of the passed redirect or postlogout redirect uri as long as it matched the wildcard pattern it would honor it.

It's not supported OOTB since it's generally regarded as a terrible practice that should really be avoided in almost all cases.
I'm sure there's a better option in your case. Could you tell me more about your scenario?

Note: if you're absolutely sure you NEED to support wildcard, you can customize the validation logic by overriding these methods:

https://github.com/openiddict/openiddict-core/blob/6ac8c2c53ef4008376b1b408d17efef13354a3b3/src/OpenIddict.Core/Managers/OpenIddictApplicationManager.cs#L1491-L1562

https://github.com/openiddict/openiddict-core/blob/6ac8c2c53ef4008376b1b408d17efef13354a3b3/src/OpenIddict.Core/Managers/OpenIddictApplicationManager.cs#L1419-L1489

... of course, I don't recommend it 😄

there a way that you know of to override just that method inside of my project inside of having to download and compile the existing repo ?

Sure, for that, you'll need to subclass OpenIddictApplicationManager<TApplication> and override the methods I mentioned. Once it's done, simply call services.AddOpenIddict().AddCore().ReplaceApplicationManager<MyApplicationManager>() to replace the default application manager by your custom one 😃

I definitely see your point though that it is a big security risk to enable that and its best practice to go ahead and manage the list to prevent any malicious behaviour that could exploit that.

👍🏻

As always I truly appreciate your help !

My pleasure!

It worked using the type.

👍🏻

Alternatively, if you prefer using a specific entity, you can use a concrete TApplication argument.
E.g if you're using EF Core: MyApplicationManager : OpenIddictApplicationManager<OpenIddictEntityFrameworkCoreApplication>

I personally prefer the open generics approach - i.e the approach you ended up with - as it's more flexible), but folks sometimes think it's a bit more complicated, so I generally suggest going with closed generics 😄

That makes me feel better ! Like I said I will probably stick with explicit redirect Uris but I love learning so it was great learning how to if i need to.

I love that attitude! ❤️ 👍🏻