Skip to content

Chukapoka/server

Repository files navigation

개발 환경으로 실행

  • IntelliJ IDEA 설치(IntelliJ IDEA Community Edition)

  • ServerApplication.kt 이동 후 해당 스타트 버튼 클릭

    project run

  • 터미널에서 실행

    $ ./gradlew bootrun

Postgresql

설치 확인 postsqlVersion.png

  • Virsion = 14.10

서비스 시작

$ brew services start postgresql

postgreStart.png

PostgreSQL 콘솔 접속

$ psql postgres

postgreConsole.png

DB 계정과 권환, Role 확인

postgres=# \du

postgreDB.png

JWT + Security 설정

  • JWT 관련
    • TokenProvider: 유저 정보로 JWT 토큰을 만들거나 토큰을 바탕으로 유저 정보를 가져옴
    • JwtFilter: Spring Request 앞단에 붙일 Custom Filter
  • Spring Security 관련
    • JwtSecurityConfig: JWT Filter를 추가
    • JwtAccessDeniedHandler: 접근 권한 없을 때 403 에러
    • JwtAuthenticationEntryPoint: 인증 정보 없을 때 401 에러
    • SecurityConfig: 스프링 시큐리티에 필요한 설정
    • SecurityUtil: SecurityContext에서 전역으로 유저 정보를 제공하는 유틸 클래스
    • CorsConfig: 서로 다른 Server 환경에서 자원을 공유에 필요한 설정

인가 표현식

API.png

hasRole과 hasAuthority 차이

hasRole은 괄호안에 USER라 넣으면 ROLEUSER로 변환 [그러니까 ROLE PREFIX를 넣지 않아야한다] hasAuthority는 ROLE_USER로 PREFIX를 넣어야한다.

hasAnyRole,Authority는 여러 권한을 넣는 것.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •