Похожие чаты

Hi. I have an existing Laravel application that I would

like to eventually migrate to ASP.NET, but there are a few things holding me back.

My application consists of an API and a website, and Laravel handles authentication for me such that when I'm logged in, I can make authenticated requests to the API from the website, without going through the API authentication process.

Can Identity or any other existing package so this for me? If not, can this be implemented as middleware?

Here is a link to the relevant doc: https://laravel.com/docs/8.x/sanctum#spa-authentication

11 ответов

15 просмотров
pete- Автор вопроса

TLDR: I'd like a way to share authentication between a razor pages website and an API within the same app such that I don't need to worry about tokens when calling the API from the website.

pete
TLDR: I'd like a way to share authentication betwe...

Cookies do that and there are simple ways to set it up in ASP.NET too.

pete- Автор вопроса
A X
Cookies do that and there are simple ways to set i...

I'd like the API to check cookies only for particular frontend domains, otherwise it should use tokens (for apps and non-whitelisted websites)

pete
I'd like the API to check cookies only for particu...

You just decorate your controllers with Authorize attribute and the authentication check happens as part of a middleware that comes with ASP.NET Core and such.

pete- Автор вопроса
A X
screenshot You just decorate your controllers with Authorize ...

I see. Thank you. I'll get started on a sample and let you know how it goes.

A X
screenshot You just decorate your controllers with Authorize ...

Role based Authorization also exists. Just a simple attribute declaration over api methods there too.

pete- Автор вопроса
A X
Role based Authorization also exists. Just a simpl...

I'll be sure to look into this as well.

pete- Автор вопроса
A X
Sure. Good luck.

It seems like the webapp scenario comes with batteries included but if I want JWT authentication I still have to do it myself. I've written middleware before to do JWT Auth for a simple Blazor PWA I had built as a demo. How could I wire this up such that asp.net falls back on jwt auth if: 1. The request is not from a whitelisted domain. 2. The request is from a whitelisted domain but does not contain a valid cookie.

pete
It seems like the webapp scenario comes with batte...

Even JWT stuff comes batteries included.

pete
It seems like the webapp scenario comes with batte...

I do not know whether that fallback is allowed. I have successfully setup projects with one or the other but never mixed them.

Похожие вопросы

Обсуждают сегодня

Господа, а что сейчас вообще с рынком труда на делфи происходит? Какова ситуация?
Rꙮman Yankꙮvsky
29
А вообще, что может смущать в самой Julia - бы сказал, что нет единого стандартного подхода по многим моментам, поэтому многое выглядит как "хаки" и произвол. Короче говоря, с...
Viktor G.
2
@Benzenoid can you tell me the easiest, and safest way to bu.y HEX now?
Živa Žena
20
This is a question from my wife who make a fortune with memes 😂😂 About the Migration and Tokens: 1. How will the old tokens be migrated to the new $LGCYX network? What is th...
🍿 °anton°
2
30500 за редактор? )
Владимир
47
а через ESC-код ?
Alexey Kulakov
29
What is the Dex situation? Agora team started with the Pnetwork for their dex which helped them both with integration. It’s completed but as you can see from the Pnetwork ann...
Ben
1
Гайс, вопрос для разносторонее развитых: читаю стрим с юарта, нада выделять с него фреймы с определенной структурой, если ли чо готовое, или долбаться с ринг буффером? нада у...
Vitaly
9
Anyone knows where there are some instructions or discort about failed bridge transactions ?
Jochem
21
@lozuk how do I get my phex copies of my ehex from a atomic wallet, to move to my rabby?
Justfrontin 👀
11
Карта сайта