ASP.NET Core Angular Authentication with Identity & EF Core

preview_player
Показать описание
ASP.NET Core minimal api & Angular authentication & authorization guide using cookies, identity framework and entity framework core.

🕰 Timestamps
00:00 Introduction
1:30 Angular pages & services scaffolding
2:35 Endpoint setup
4:40 login & logout
8:17 fetch user
12:50 identity & ef core
22:40 register page
26:45 data entities & endpoints
29:00 manager & admin authorization
32:10 seed data
34:58 final demo
39:34 The End

👉 Try Rider
RD5K9-4TXXW-KMV3G-NYWSF-3ZSTP

#aspnetcore #angular #authentication
Рекомендации по теме
Комментарии
Автор

Really heplful. Love your .NET Core series. As a frontend developer was strugling to implement proper auth with Identity on my project, this series really helped a lot to wrap my head around it.

hangor
Автор

6:56 the software engineers mindset, love that! amazing videos as always

AnsisPlepis
Автор

This was very helpful. By following this video, I was able to add authentication to a React + .NET Web API application.

saurabhumadikar
Автор

im about to start a job where I am gonna be doing this. Thanks for the tutorial!!!! Likely gonna be coming back to ask a question lol

a_ghoul
Автор

As I've seen from TS developer, he returns Observable<T> from HttpClient

agentvettel
Автор

👍👍 Can you make another version of this video with React please?

jeheecheon
Автор

Excellent video, very well explained. But man, that keyboard sound! What is it?

tsankotsankov
Автор

Спасибо большое за видео, как раз то, на чем я делаю проект) Ты крут)

agentvettel
Автор

Thanks for that video - it was really helpful.
I am just wondering - if I am using a JWT auth - is there a possibility to connect it through SignInManager ?

pd
Автор

Nice explanation. Can you please do a video about user impersonation using JWT/Identity. Thanks

onedev
Автор

Hell yeah!!! I'm surprised that you're not Angular kind of guy, considering dotnet background. But you swim rather smoothly in it... Either that, or editing this video was a bitch.

cocoscacao
Автор

How do I in this approach modify cookie expiration time, rename cookie, enable SlidingExpiration ? I believe when adding cookie through "AddIdentity" method we cannot do this, am i right ?

kamilkosobudzki
Автор

I feel this fresh look api in dotnet kinda like laravel

sulaimantriarjo
Автор

it's great, but i has next problem whats don't know how fix. On deploy angular has other adress with .net deplot proj, i can send request on backend but his not return cookie auth, but i know 100% whats backend put me that in frontend? baecause if i use httpclient on localhost without write baseurl he s return me a cookie every try

АртемДенисенко-кя
Автор

Now we need nuxt version with gated serverside content

elraito
Автор

Doesn't dotnet Identity saves a cookie as encrypted And if cookie get encrypted then do we need a separate api to get user info and save it may be on local storage.

TheAzerue
Автор

does anyone know why I get a 405 on all my POSTS but not GETS? I'm assuming it's a CORS issue, but I'm not sure. Any help would be appreciated.

kaseabernathy
Автор

I thought you were about to commit a sin. Good thing you don't do angular.

shadmansudipto
Автор

12:07 I suggest viewers to use httpClient better :D

Namely:
Services are places where communication with api's happens but also they are responsible for holding the state

so sample AuthService could look like this:

@Injectable({ providedIn: 'root' } // By doing so we don't need to specify this service in the providers array, it will become singleton, and we can inject it everywhere in the app
export class AuthService {
user: User | null // this can be either User class directly or Subject/ReplaySubject <User>, by making this a subject we can later in the app wire things up reactively

login(login: string, password: string): Observable<User> {
return this._http.post(url, { body }).pipe(
tap((user) => this.user = user)); // rxjs tap operator is for producing side effects, so it is perfect to assign our user property of the service
)

logout(): Observable<void> {
return this._http.post(...).pipe(
tap(() => this.user = null)
)
}
}
}

Then in the component you can use it like this: this._authService.login("anton", => { ..Whatever you want to do with that user })

If you need to access user data later on, you can do this by reffering to the user property of AuthService. I was writing this without IDE so there could be mistakes

Kosa
welcome to shbcf.ru