Authentication Methods in ASP.NET Flashcards

1
Q

What are the most common methods of authentication?

A

Cookie-based
Token-based
Third-party (OAuth, API-token)

Also OpenID, Security Assertion Markup Language)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is cookie-based authentiation?

A

Authentication users by storing details in browser cookies.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is token-based authentication?

A

Server generates a token which is stored on client and sent with each request.

Commonly used for API’s

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is OAuth?

A

A user can sign in on one website and be authorised to perform actions on another.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are the two OAuth Flows?

A
  • Authorisation Code Flow
  • Implicit
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

When is the Authorization Code Flow used?

A

Web application that can store a client secret

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

When is the Implicit Flow used?

A

Web application that can not store a client secret

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Which Authentication Flow is more secure?

A

Authorisation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Describe the Authorisation Code Flow?

A
  1. **Client **requests Authorisation Code from Authorisation Server.
  2. Authorisation Server authenticates Client and asks User to grant permission to Client.
  3. User grants permission to Client.
  4. Authorisation Server sends Authorisation Code to Client.
  5. **Client **requests Access Token from Authorisation Server in exchange for Authorisation Code.
  6. Authorisation Server verifies Authorisation Code and sends Access Token to the client.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Describe the Implicit Code Flow?

A
  1. Client sends request for Authorisation Server to obtain an Access Token.
  2. **Authorisation Server **authenticates the Client and asks the User to grant permission to the Client.
  3. The User grants permission to the Client.
  4. The **Authorisation Server **sends an Access Token to the Client.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What two main types of Authentication do you use in ASP.NET Core?

A
  • Cookies
  • JWT
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is the main difference between Cookie and JWT authentication in ASP.NET?

A
  • Cookies small text files stored client-side
  • JWT self-contained and signed. More secure as no information client-side
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How do you implement Cookie Authentication in ASP.NET?

A

In startup.cs ConfigureServices

services.AddAuthentication(…).AddCookie(…)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How do you implement JWT Authentication in ASP.NET?

A

In startup.cs ConfigureServices

services.AddAuthentication(…).AddJwtBearer(…)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Which validation parameters do you need to set with JWT Authentication?

A
  • Issuer
  • Audience
  • Signing Key
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How can you add a users Role to a Jwt?

A

Using Claim class

Create a list and add

new Claim(ClaimTypes.[Name/Role etc…], “Item”)