Jongmo-kim / Personal-NAS

0 stars 0 forks source link

일부 백엔드 요청에 대해 권한을 추가합니다. #28

Open Jongmo-kim opened 2 years ago

Jongmo-kim commented 2 years ago

일부 백엔드 요청들은 권한에 따라 수행되지 않도록 설정해야합니다.

현재 구상중인 방법은 세션-쿠키 방식입니다. 하지만 REST 아키텍쳐는 stateless 제한, 즉 세션과 같은 상태를 저장해서는 안되므로 다른 방식이 적용되야 합니다. 이를 조사하여 적용합니다.

Jongmo-kim commented 2 years ago

session이 rest 원칙을 위반하는지

That said, authentication and client side state do not violate REST principles. https://stackoverflow.com/questions/6068113/do-sessions-really-violate-restfulness

해당 글을 읽어보면 전반적으로 세션을 사용하는것에 대해서는 원칙을 위반하는것이 아니라고 합니다.

Any client issuing an identical request (same headers, cookies, URI, etc) should be taken to the same place in the application. If the website stored the current location of the user and managed navigation by updating this server side navigation variable, then REST would be violated.

그중 내용을 일부 발췌한 내용에 따르면 헤더와 쿠키 URI이 등이 같은 요청에 대해 항상 같은 내용을 표시해야 한다고 합니다. 만약 요청에 대해 기록해 두었다가 동일한 요청이 발생해서 내용이 바뀐다면 그것이 rest원칙을 위반하는 것 이라고 합니다.

There should not be any session affinity or sticky session between the client and the server. https://restfulapi.net/statelessness/

하지만 restfulapi.net에서는 위와 상반된 얘기를 하고있습니다.

Storing session state on the server violates the stateless constraint of the REST architecture. So the session state must be handled entirely by the client. https://stackoverflow.com/questions/34130036/how-to-understand-restful-api-is-stateless

좀더 살펴보니 클라이언트 쪽에서는 세션을 조작해도되지만 백엔드에서는 조작하면 안된다(?)라는 내용도 있었습니다.

따라서 세션방식 외에 다른 방식을 조사합니다.

Jongmo-kim commented 2 years ago

Spring securty 라는 스프링 프레임 워크가 존재합니다. 조사해보니 어떤 spring boot 프로젝트는 spring security를 사용하여 인증 및 권한 설정을 하고 있음을 파악했습니다. spring security 적용 사이트

spring security가 session을 사용하는지, 사용한다 하더라도 원칙을 위반해서라도 인증/인가/ 권한 설정 과 같은 로직을 일임할수 있다면 전반적인 코드의 양이 줄어들기에 이를 조사해봅니다.