Похожие чаты

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 ответов

7 просмотров
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.

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

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

Всем привет, написал код ниже, но он выдает сегфолт, в чем причина? #include <stdio.h> #include <stdlib.h> #include <string.h> struct product { char *name; float price; };...
buzz базз
60
Хотел бы спросить у знающих, правильную ли я выбрал книгу для начала изучения ассемблера Юрова В.И ? Или есть более лучшие книги для начала обучения?
Botsman
25
Добрый день, не подскажите, если в OC-V3 поменять страндартную директорию /storage/ на /storage2/ - не будет сильно много проблем ?
Max Dubovsky
32
Conversation at a festival with a non-crpto person (not a normie by any stretch, though): * person: tell me about crypto, me: ok, the original idea is p2p sound money for the...
molecular#123 🐓
25
Книга Юрова В.И пойдёт для обучения?
Botsman
24
$params = [ 'formid' => 'feedbackForm', 'formTpl' => '@CODE: <form class="form-validate" data-id="ajax_form"> <fieldset class="margin-bottom-md"> ...
Pathologic
1
> Примечательно, что новый владелец удаляет из GitHub любые жалобы, указывающие на подозрительную активность или смену владельца, и, видимо, рассчитывает на то, что пользовате...
Alex Sherbakov
2
Today, DENT achieved a significant step forward in DENTX adoption 🥳 Getting DENTX and starting staking is much easier: DENTX is available on Uniswap! Everyone can swap their ...
Thomas
3
I bought some PHA tokens on Kucoin, which is the best wallet to store and easy to use?
AMR
19
Hey there Which is the best Linux destro for developers (coding)? To my research on reddit, they said Linux mint is good for mid level spec and Ubuntu for high Lev hardwar...
Wiz 🪄
11
Карта сайта