Spring-Security-101 Flashcards

1
Q

Which min java version is required for Spring security?

A

8

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

What is the artifactid for spring security?

A

spring-boot-starter-security

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

What is full form of CSRF?

A

Cross Site Request Forgery

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

What is Synchronizer Token Pattern?

A

It requires that each http request must contain random token name csrf

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

How can an eavesdropper cannot read the csrf token?

A

Because it is encryted and also the same origin policy restricts

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

What is a Same Site attribute in cookies?

A

This attributes has two values , String and LAx
The Strict says the cookin must come from the same site, or else cookie wont be included, Lax says the request could come from the top level domain

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

In case because of Samesite attribute, the cookin is not included, how will it save the CSRF attack?

A

As cookies has the sessionid included, since the cookie wont be inculded in case of not the same site. Thus the absence of session id .

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

How we can let the MPfile to be uploaded with csrf security?

A

We can use the CSRF attache din Body ( this ill lead to upload and read the temporary file) or in URL param(not recommended)

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

What is the role of cache headers i it?

A

By default the caching is disabled for all sorts of http request and resources, but yes can be tweaked.
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0

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

What is content-sniffing?

A

There are many browsers like that reads the content-type first of the resources send for a bettter UX.

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

What is the issue associated with content-sniffing?

A

It will help attackers to post an XSS attack

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

What is XSS?

A

Cross-Site Scripting

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

How does SSecure safeguards the content-sniffing?

A

Bu adding the http header: X-Content-Type-Options: nosniff

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

What is the full form of HSTS?

A

Http Strict Transport Security

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

What is HSTS?

A

So it hap[pens when a user has typed without https, this will add the site to the browser by default https prptocol list

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

How can it be HSTS list be preloaded into the browser?

A

By somehow preleading while updates or if the bank is called then adding the Strict-Transport-Security: max-age: … header

17
Q

How can we avoid clickjacking

A

With X-Frame-Options: Deny header

18
Q

What is CSP full form?

A

Content-Security-Piloicy

19
Q

What is CSP?

A

it is to mitigate the XSS and the like attakcs.It makes the browser to guide what to do and and from where to do, for e.g. Content-Security-Policy: script-src domain.com… says from where only to load the scripts

20
Q

Can SSecurity routes http to https site?

A

YEs

21
Q

How can SS helps in removing the load balancer fog?

A

By using server.use-forward-headers

22
Q

What is JOSE

A

Javascript Object Signing & Encryption

23
Q

What all standards come in JOSE?

A

JWT(Json Web Token)
JWS(JSOn Web Signature)
JWE(Json Web Encryption)
JWK(Json Web Key)

24
Q

How does SpSec gets integrated with Servlet Container?

A

By using a fileter: Filter

25
Q

Can we use Spring in any Servlet based app?

A

Yes, because it just need to have the “Filter”

26
Q

How does SpSec enables the Security?

A

SpSec by default enables a Filter named : SpringSecurityFilterChain, This is a bean.

27
Q

What is JAAS?

A

Java Authentication and Authorization Service Policy File

28
Q

What is core component for SpSec?

A

spring-security-core

29
Q

What is SecurityContextHolder?

A

It is the fundamental context in Spring Security, and it knows the Principle currently using the app. IT store the info in Threadlocal.

30
Q

Generally few apps like Desktop doesnot use the Threaloacal ?

A

Yes So SpringContextHolder can be used to use other mechaniism

31
Q

How can we obtain the info about current user?

A

Using Authentication object, populated by SpSec.
Object principle = SecurityContextHolder.getContext().getAuthentication().getPrinciple();

if(principle instanceof UserDetail)
username = (UserDetails) principle.getUserName();
else
username = principle.toString()

32
Q

What is getContext()

A

It gives impl of SecurityContext interface

33
Q

What is UserDetails

A

It is an adapter between user database or storage and the spring security

34
Q

Hos do the userdetail is captured inside SpSec?

A

UserDetailsService interface , it gives only one method and accepts only String username to create the userDetail object.

UserDetails loadUserByName(String username) throws UserNotFoundException

35
Q

What happens after successful authentication?

A

The UserDetails obj is used to build the Authentication object which gets stored in SecurityContextHolder

36
Q

Can we extend UserDetailService object?

A

Yes many object in Security-core cant be extended without crude purpose, and USerDetailsService Object can be extended , it also uses InMemorMap and JdbcDaoImpl

37
Q

What basically is UserDetailService>?

A

It is basically a Dao Sort of Object

38
Q

What is GrantedAuthority?

A

to reflect the applicaion-wide permission given to a principle

39
Q

What are the most basic operations go inside SpSec?

A

When a user logs in with UN and PW , a UsernamePasswordAuthenticationToken (an instance of Authentication interface), this token is passed to the AuthenticationManager to for validation, The AuthenticationManager rerurn Authetication Object, and then SecurutyContext is called by using SecurityContext.getContext,getAuthentication()…