Authentication Flashcards

(45 cards)

1
Q
  • __________ is the process of verifying that someone is who they say they are.
  • Involves granting access to resources based on someone’s identity.
A

Authentication

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

Reasons for authentication

A
  1. Saving client-client data
  2. Customizing User Experience
  3. Authorization / Usage Control
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

True or False

Authentication and Authorization are the same. They are used in conjunction with each other.

A

False

Authentication and Authorization are related, but different concepts. They are used in conjunction with each other.

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

True or False

Authorization can’t happen without authentication. A user can be authenticated, but not authorized to access a particular resource.

A

True

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

What do we need for authentication?

A

1. Credentials
an identity and an authentication factor
e.g. username and password OR email and password authentication can be multi-factor
e.g one-time-pin sent through email or an app (aside from the actual password)
<br></br>
2. Authentication token or session id from the server.
used for subsequent requests that require authentication

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

True or False

After a user logs in, they shouldn’t have to authenticate again.

A

False

After a user logs in, they shouldn’t have to authenticate again until they log out or the session expires.

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

Servers ‘remember’ users with the use of ________ or sessions.

A

cookies

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

2 kinds of auth

A
  1. Token Based Auth
  2. Session-Based Auth
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

The authenticating server gives out tokens to clients.

A

Token-based authentication

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

A ________ is a string of data.

A

token

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

eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.ey JzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6Ikpva G4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKx wRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c

A

Sample token

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

________ can be used for things other than authentication (holding identity data, getting more auth tokens, etc.)
They are a generic medium of information

A

Tokens

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

A 1. ________ message means that its origin can be verified. An 2. ________ message means that only its intended recipient can read it.

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

True or False

Clients do not necessarily send an auth token with every request that needs authentication.

A

False

Clients send an auth token with every request that needs authentication.

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

True or False

  • The authenticating server issues tokens when clients log in.
  • However, it doesn’t keep track of logged in users.
  • The server only checks the validity of submitted tokens (not yet expired, untampered).
A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q
  • In ________________, the server keeps track of a list of active sessions. It gives logged in users a session id (usually in a cookie).
  • Users use their session ID to maintain their logged in state as they use the web app.
A

Session-based auth

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

Heavy lifting is done server-side. The ________ keeps all the session data.
<br></br>
vs. Token-based: all ‘session info’ can be kept in the token.

A

server

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

True or False

Credentials are sensitive information and should be sent over the network as little possible.

A

True

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

True or False

Tokens and Sessions can be revoked to terminate a logged in ‘session’ as needed.

20
Q

A _________ is a small piece of data that the server sends to the user’s browser via a header in the response message.

21
Q
  • Browsers store this data and, until it expires, include it with all requests sent to the origin server
  • Typically used by the server to tell if 2 requests came from the same browser.
22
Q

Uses for cookies

A
  • Session Management
  • Personalization
  • Tracking
23
Q

Types of Cookies

A
  • Session Cookies
  • Permanent Cookies
24
Q

Have an expiry date and time set during its creation. They are automatically deleted by the browser.

A

Permanent Cookies

25
Don't have a specified expiry. They are deleted when the client (browser) shuts down.
Session cookies ## Footnote (However they can be be restored using a browser feature called session restoring)
26
# True or False Because of session restoring, Session cookies are practically permanent, in practice.
True
27
These cookies are inaccessible via JS/DOM methods. They are only stored, and sent directly to the server.
Secure/HttpOnly Cookies
28
* aren’t really a third typeof cookie. * Session and permanent cookies can have the additional property of being secure.
Secure/HTTPOnly cookies
29
# True or False Cookies are the things that cross-site scripting attacks want to steal. Like the Same-origin Policy, secure cookies are a security measure.
True
30
The W3C spec for cookies doesn’t include a size limit. But in practice: _\_\_\_
~4KB
31
# Token-Based vs Session-Based In session-based, heavy lifting is done _\_\_\_\_\_\_\_\_. The server keeps all the session data.
server-side
32
Options for storing session data in the server
1. Main memory (in a running program) 2. Database storage
33
Options for token storage on client side
1. Browser sessionStorage 2. Browser localStorage 3. Cookies 4. A variable in a program / main memory (if request is not handled by a browser)
34
Session storage and Local storage are forms of browser storage introduced in _\_\_\_\_\_\_\_\_.
HTML 5
35
# True or False Like cookies, data in local/session storage is not associated with an origin.
False ## Footnote Like cookies, data in local/session storage **is** associated with an origin.
36
# True or False But usage of local/sessionStorage is not tied to a header like Set-Cookie or Cookie.
True
37
Options for sending auth tokens to a server
1. As a cookie 2. In the Authorization Header of a request 3. In the URL
38
* In _\_\_\_\_\_\_\_\_\_, all the session info can be kept in the token. It’s easy to scale horizontally. * Adding more concurrent users doesn’t add a proportional amount of load on the servers.
token-based
39
Web Storage API’s 1. _\_\_\_\_\_\_\_\_\_ and 2. _\_\_\_\_\_\_\_\_\_can store more data than a cookie
localStorage sessionStorage
40
* _\_\_\_\_\_\_\_\_\_\_\_ auth is becoming more popular because of the popularity of APIs, and the separation of back-end and front-end. * The authenticating server might be different from the web app server.
Token-based
41
# True or False In practice, web apps commonly use only one of either token or session-based auth.
False ## Footnote In practice, web apps commonly use a **combination of both** token and session-based auth.
42
* HTTP with _\_\_\_\_\_\_\_(HTTPS) is important for either implementation. * Without _\_\_\_\_\_\_\_, a middleman can read the contents of all the messages you exchange with a server, and can steal cookies, tokens, or credentials.
TLS
43
Implementation: Simple Token-Based Auth
* Express JS * MongoDB/Mongoose JS * Json Web Tokens * Cookie Parser * bcrypt
44
To Implement:
1. Sign Up 2. Log In 3. Restrict Dashboard page 4. Log Out
45
# Authentication Tasks Server: Client:
Server 1. Give out tokens to authenticated clients (‘signing’ tokens) 2. Verify validity of tokens sent by clients Client 1. Store the auth token received from server 2. Send auth token to server again whenever necessary