Authentication Methods in ASP.NET Flashcards
What are the most common methods of authentication?
Cookie-based
Token-based
Third-party (OAuth, API-token)
Also OpenID, Security Assertion Markup Language)
What is cookie-based authentiation?
Authentication users by storing details in browser cookies.
What is token-based authentication?
Server generates a token which is stored on client and sent with each request.
Commonly used for API’s
What is OAuth?
A user can sign in on one website and be authorised to perform actions on another.
What are the two OAuth Flows?
- Authorisation Code Flow
- Implicit
When is the Authorization Code Flow used?
Web application that can store a client secret
When is the Implicit Flow used?
Web application that can not store a client secret
Which Authentication Flow is more secure?
Authorisation
Describe the Authorisation Code Flow?
- **Client **requests Authorisation Code from Authorisation Server.
- Authorisation Server authenticates Client and asks User to grant permission to Client.
- User grants permission to Client.
- Authorisation Server sends Authorisation Code to Client.
- **Client **requests Access Token from Authorisation Server in exchange for Authorisation Code.
- Authorisation Server verifies Authorisation Code and sends Access Token to the client.
Describe the Implicit Code Flow?
- Client sends request for Authorisation Server to obtain an Access Token.
- **Authorisation Server **authenticates the Client and asks the User to grant permission to the Client.
- The User grants permission to the Client.
- The **Authorisation Server **sends an Access Token to the Client.
What two main types of Authentication do you use in ASP.NET Core?
- Cookies
- JWT
What is the main difference between Cookie and JWT authentication in ASP.NET?
- Cookies small text files stored client-side
- JWT self-contained and signed. More secure as no information client-side
How do you implement Cookie Authentication in ASP.NET?
In startup.cs ConfigureServices
services.AddAuthentication(…).AddCookie(…)
How do you implement JWT Authentication in ASP.NET?
In startup.cs ConfigureServices
services.AddAuthentication(…).AddJwtBearer(…)
Which validation parameters do you need to set with JWT Authentication?
- Issuer
- Audience
- Signing Key