aspnet / Security

[Archived] Middleware for security and authorization of web apps. Project moved to https://github.com/aspnet/AspNetCore
Apache License 2.0
1.27k stars 600 forks source link

How to create a custom authentication middle-ware in 2.0? #1345

Closed malichishti closed 7 years ago

malichishti commented 7 years ago

Hi,

I need to create a custom auth middle-ware. I have been following instructions here but unfortunately i'm unable to find respective base classes in Core 2.0; is it still possible to achieve something similar in 2.0?

Regards, Ali

Tratcher commented 7 years ago

Quite a bit has changed for authentication authors. Reviewing a similar implementation might be the best way to get started. https://github.com/aspnet/Security/tree/a4458191c700437a00603116ad92633d1590319d/src/Microsoft.AspNetCore.Authentication.JwtBearer

Highlights: You don't need a middleware class anymore, just the handler class. The registration has moved from Configure to ConfigureServices Options are injected via DI https://github.com/aspnet/Announcements/issues/262

blowdart commented 7 years ago

A simpler sample to follow might be https://github.com/blowdart/idunno.Authentication which is stripped down to the bare minimum.

malichishti commented 7 years ago

@Tratcher Thank you that solved my problem.

@blowdart thank you for the link, however that approach doesn't work anymore as those base classes have changed: image

HaoK commented 7 years ago

Make sure you look at the core2-rtm branch not master

blowdart commented 7 years ago

What @HaoK said :) That's up to date as of Sunday.