ASP.NET CORE Authentication & Authorization Flow | ASP.NET Core Identity Series | Episode #2

Frank Liu
28 Apr 202106:44

Summary

TLDRThe video explains the process of authentication and authorization in web applications. It describes how a user interacts with a login page, submits credentials, and how the server verifies these credentials against a data store. Upon successful verification, a security context is generated, serialized into a cookie, and sent back to the browser. Each subsequent request carries this cookie, which the server decrypts to authenticate the user again. The video also clarifies that authentication verifies identity, while authorization checks if the user has permission to access certain resources.

Takeaways

  • 🔐 **User Interaction**: The process begins with a user entering credentials on a login page.
  • 🌐 **HTTP Request**: The entered credentials are sent to the server via an HTTP request.
  • 🔍 **Verification Against Data Store**: The server verifies the credentials against a user data store, typically a database.
  • 🆔 **Identity Verification**: If the credentials are correct, the server retrieves the user's identity information.
  • 🛡️ **Security Context Generation**: The identity information is used to create a security context.
  • 🍪 **Cookie Serialization**: The security context is serialized into a cookie, which is a piece of data stored in HTTP headers.
  • 🔒 **Cookie's Domain Restriction**: Cookies are restricted to the same domain for security reasons, preventing cross-domain sharing.
  • 🔄 **Subsequent Requests with Cookies**: Every subsequent HTTP request includes the cookie for authentication purposes.
  • 🔑 **Cookie Decryption and Deserialization**: The server decrypts and deserializes the cookie to verify user authentication.
  • ✅ **Authorization Check**: Once authenticated, the server checks if the user is authorized to access the requested information.
  • 📄 **Data Delivery**: If authorized, the server returns the appropriate response containing the required data.

Q & A

  • What is the primary focus of the video?

    -The video primarily focuses on explaining the process of authentication and authorization in web applications in more detail than the previous video.

  • What is the first step a user takes to access a web page that requires login?

    -The first step a user takes is to enter their credentials into the login page through the browser.

  • How is the user's credentials sent to the server?

    -The user's credentials are sent to the server as part of an HTTP request.

  • What does the server do upon receiving the credentials?

    -Upon receiving the credentials, the server verifies them against a user store, typically a database, to ensure they are correct.

  • Why is a database symbol used in the explanation?

    -A database symbol is used to represent the data store where user information is stored, against which the credentials are verified.

  • What is the purpose of generating a security context after verification?

    -The purpose of generating a security context is to establish the identity of the user and prepare it for serialization into a cookie.

  • What is a cookie in the context of web applications?

    -A cookie is a piece of information stored in the header of HTTP requests and responses that is carried between the browser and the web server, and is specific to the same domain.

  • Why is the authentication process repeated after the initial login?

    -The authentication process is repeated to verify the user's identity with each subsequent request by deserializing the security context from the cookie.

  • How does the server know if the user is logged in?

    -The server knows if the user is logged in by deserializing the security context from the cookie, which indicates the user's authentication status.

  • What is the difference between authentication and authorization as explained in the video?

    -Authentication is the process of verifying the user's identity, while authorization is the process of determining whether the authenticated user has access to the requested information or page.

  • What happens if the user is authorized to access the requested information?

    -If the user is authorized, the web server returns the appropriate response containing the HTML and data required by the user.

Outlines

00:00

🔐 Web Application Security: Authentication Flow

This paragraph explains the process of user authentication in a web application. It begins with a user attempting to access a web page that requires login. The user enters credentials through a browser, which are then sent to the server via an HTTP request. The server receives these credentials and verifies them against a user store, typically a database. If the credentials are correct, the server generates a security context using the user's identity information. This security context is then serialized into a cookie, which is a piece of information stored in the HTTP request and response headers that is exchanged between the browser and the server. The cookie is domain-specific, ensuring security by not being shared across different web servers. The authentication process includes verifying the user's identity and generating the security context, which is then sent back to the browser in a serialized form as a cookie. Each subsequent HTTP request made by the browser will include this cookie, allowing the server to deserialize the security context and authenticate the user for access to the requested resources.

05:03

🔐 Web Application Security: Authentication and Authorization

The second paragraph delves into the concepts of authentication and authorization within web application security. Authentication is defined as the process of confirming a user's identity, which in this context is done by decrypting and deserializing a cookie stored in the browser. The security context, once obtained from the cookie, helps determine if the user is authenticated. Following authentication, authorization comes into play, which is the step that decides whether the authenticated user has the necessary permissions to access the requested information or page. The paragraph emphasizes that while authentication is about verifying who the user is, authorization is about determining what they are allowed to do. The process concludes with the server returning the appropriate response containing HTML and data if the user is both authenticated and authorized.

Mindmap

Keywords

💡Web Application Security

Web Application Security refers to the measures taken to protect web applications from attacks and vulnerabilities. In the video, this concept is central as it discusses how to secure user data and interactions within a web application environment. The script mentions securing login pages and verifying user credentials, which are key components of web application security.

💡HTTP Request

An HTTP Request is a message sent from a client to a server to request access to a resource. In the script, the user enters credentials which are then sent to the server via an HTTP request. This request is a fundamental part of the authentication flow, as it carries the user's login information to the server for verification.

💡Server

The server in this context is the system that hosts the web application and handles requests from clients. The script describes how the server receives credentials from an HTTP request and verifies them against a user store. The server plays a critical role in the authentication process by determining if the provided credentials are valid.

💡User Store

A user store is a database or data store that contains user information, including credentials. The script mentions the server verifying credentials against a user store to ensure they are correct. This is a vital step in the authentication process, as it confirms the user's identity against stored data.

💡Security Context

The security context is a set of information that defines the security state of a user or process. In the video script, once the user's credentials are verified, the server generates a security context. This context is then serialized into a cookie, which is used to maintain the user's authenticated state throughout their session.

💡Cookie

A cookie is a small piece of data stored on the user's computer by the web browser. The script explains that after a user is authenticated, a cookie is sent back to the browser. This cookie is then included in every subsequent HTTP request, allowing the server to recognize the user's authenticated state.

💡Authentication

Authentication is the process of verifying the identity of a user. The script describes authentication as the process of checking the user's credentials and generating a security context. It is a critical step in ensuring that only legitimate users can access certain parts of a web application.

💡Authorization

Authorization is the process of determining whether an authenticated user has permission to access a specific resource. The script mentions that after authentication, the server decides if the user is authorized to access the requested information. This step ensures that users can only access resources they are permitted to see.

💡Credentials

Credentials are pieces of information used to authenticate an identity. In the script, the user enters their credentials, which are then sent to the server for verification. Credentials typically include a username and password, and are essential for determining if a user is who they claim to be.

💡Data Store

A data store is a repository for storing and managing data. In the context of the video, the data store is where user information, including credentials, is kept. The server verifies the credentials against this data store to authenticate the user. The data store is a key component in maintaining the integrity and security of user data.

💡Encryption

Encryption is the process of encoding information in such a way that only authorized parties can access it. The script mentions that the cookie, which contains the security context, is encrypted. This ensures that even if the cookie is intercepted during transmission, the information it contains cannot be read without the proper decryption key.

Highlights

The video discusses security in web applications with a focus on user authentication and authorization.

The user accesses a login page to enter credentials for secure information access.

Credentials are sent to the server via an HTTP request.

The server verifies credentials against a user store, typically a database.

Verification process is represented by a rectangle in the flow diagram.

If credentials are correct, identity information is used to generate a security context.

Security context is represented by a second rectangle in the flow diagram.

The security context is serialized into a cookie for storage and transmission.

Cookies are pieces of information stored in the HTTP request and response headers.

Cookies are limited to sharing within the same domain due to security reasons.

The authentication process involves verifying the user and generating a security context.

The authentication process also includes deserializing the security context from the cookie.

Authorization follows authentication to determine access rights to information or pages.

The video emphasizes that both authentication and authorization are crucial for secure web application access.

Decrypting and deserializing the cookie is part of the ongoing authentication process.

The security context, contained in the HTTP context object, determines user authorization.

The video concludes by explaining the conceptual simplicity of authorization compared to authentication.

Transcripts

play00:00

in the previous video i covered a little

play00:02

bit about

play00:03

security in web application in this

play00:06

video i want to cover

play00:08

still on high level but i want to

play00:10

provide a little bit more detail

play00:12

in terms of the flow so if

play00:16

we have a user here trying to access a

play00:19

web page

play00:20

right let's imagine this login page is

play00:22

already loaded

play00:23

because the the user wants to access

play00:26

some information that requires uh

play00:30

login right so the user would interact

play00:32

with

play00:33

this browser to enter the the

play00:36

credentials

play00:37

right so once the credential is entered

play00:40

a http request and then it's sent to the

play00:43

to the server okay so let's use this

play00:46

arrow to

play00:47

represent the http request that is sent

play00:49

to the server

play00:50

when the server receives the credentials

play00:52

from the http request body

play00:55

it's going to then verify against

play00:58

a user store to make sure the

play01:01

credentials

play01:02

are correct why do i draw

play01:05

a database symbol here that's because

play01:08

the user information is stored

play01:10

usually in the data store right so

play01:14

the credentials need to be verified

play01:16

against the user's

play01:18

data store right so this part this step

play01:21

will happen and if the verification is

play01:25

completed correctly that means the

play01:28

credentials are correct the identity

play01:30

will come back

play01:31

the identity information will be used to

play01:34

generate

play01:35

the security context so let's use this

play01:40

rectangle to represent this verification

play01:44

process

play01:45

verify credentials

play01:48

and then we're going to use this second

play01:50

rectangle to represent the process

play01:52

of generating the security

play01:57

context so after the verification

play02:00

the identities will be pulled into

play02:03

the web server and store those

play02:06

identities in the security context and

play02:08

then serialize that

play02:10

into a cookie if you're not very

play02:12

familiar with the concept of cookie

play02:15

i just want to add a little bit

play02:17

information here a cookie can

play02:19

be considered as a piece of information

play02:21

that is

play02:22

stored in the header of the http request

play02:26

and http response right that information

play02:29

is

play02:30

going to be carried back and forth

play02:34

between the browser and the web server

play02:37

and there is a feature

play02:38

with this piece of information because

play02:41

in the header you can contain

play02:42

lots of information but the cookie is a

play02:46

special type of information

play02:48

because it can only be shared within the

play02:50

same

play02:51

domain right you cannot

play02:54

uh send a request to a different web

play02:57

server

play02:58

that carries the same cookie because

play03:00

because there is

play03:01

a security problems all right let's go

play03:04

back to this

play03:05

authentication and authorization flow so

play03:08

let's imagine this is a cookie a normal

play03:10

cookie authentication which is very

play03:11

suitable for this

play03:13

application right so then this

play03:18

serialized cookie will be contained in

play03:21

the http response

play03:22

and then will be returned back

play03:26

to the to the browser the browser

play03:30

will then redirect the user

play03:33

to a different

play03:36

page right and including that

play03:39

redirection

play03:40

every single subsequent http request

play03:44

will contain that cookie right so let's

play03:48

use another arrow

play03:52

to represent one of the subsequent

play03:55

requests and then this rectangle

play03:59

will represent the authentication

play04:03

process so you may ask why this is

play04:06

authentication where this

play04:07

is already the verification process is

play04:10

already

play04:10

authentication right so yes this

play04:14

part this whole part here the both of

play04:17

the

play04:18

these rectangles are part of

play04:20

authentication

play04:22

right uh to verify the user is

play04:25

who they say they are and then generate

play04:28

the security context

play04:29

serialize that into a cookie sends that

play04:32

back

play04:32

to the browser so this is all

play04:34

authentication process

play04:36

why would we have this authentication

play04:38

process again well here

play04:40

we have it in the cookie right we have

play04:43

these security contacts in the cookie

play04:45

uh the the web server will have to

play04:46

deserialize that into the security

play04:48

context

play04:49

and then the the web server will

play04:53

actually know whether the user is is

play04:55

actually logged in or not

play04:56

right so this part of deserializing uh

play04:59

the security context from the cookie

play05:02

is also part of authentication right so

play05:06

so basically

play05:07

in one statement authentication is the

play05:09

process

play05:10

to know who you are okay so

play05:13

because the security context is already

play05:15

stored in the cookie

play05:17

so in order to know at this step in

play05:20

order to know who you are

play05:22

it only needs to decrypt that cookie and

play05:24

deserialize that cookie

play05:26

because the cookie is encrypted so once

play05:30

those happens immediately we know

play05:32

whether the user is authenticated

play05:34

or not so this is still the

play05:37

authentication

play05:38

process where we decrypt the cookie we

play05:41

deserialize the cookie to get the

play05:43

security context

play05:44

and then once we have the security

play05:48

context

play05:49

which is actually contained in the http

play05:51

context object

play05:53

right once we have that information then

play05:55

we can tell whether

play05:56

the user is authorized

play05:59

to access the information or the page

play06:03

it wants to see right so that's the

play06:05

second step which is

play06:06

authorized authorization okay so

play06:10

authorization

play06:11

will happen right afterwards

play06:14

and then and then if everything is okay

play06:16

then the web server will decide to

play06:19

return the proper response that contains

play06:22

the

play06:22

html and all of the data that the user

play06:25

requires

play06:26

from this video i wanted to show you

play06:29

that

play06:30

both these steps as well as these

play06:33

are part of authentication

play06:36

and then the authorization process is

play06:39

relatively

play06:40

simpler from at least conceptual level

Rate This

5.0 / 5 (0 votes)

Ähnliche Tags
Web SecurityAuthenticationAuthorizationUser LoginHTTP RequestsCredentials VerificationSecurity ContextCookie SerializationData StoreWeb Server
Benötigen Sie eine Zusammenfassung auf Englisch?