Project

일반

사용자정보

DCAMP FRONTEND API 개발 가이드 » 이력 » 개정판 5

개정판 4 (최시은, 2023-05-25 23:36) → 개정판 5/31 (최시은, 2023-05-25 23:53)

h2. DCAMP FRONTEND API 개발 가이드 

 1. SecurityConfig 설정(security/config/SecurityConfig.java) 
 *    securityFilterChain 메소드 - 개발 진행할 URL 에 대한 hasAuthority 룰 추가 
 <pre><code class="java"> 
 http.csrf().disable() 
      .authorizeHttpRequests((authorize) -> 
            authorize 
                // hasAuthority 사용: db에 ROLE_ 안붙여도 됨 
               .requestMatchers("/projects/**").hasAuthority("ADMIN") // 관리자 : ADMIN | 작업자&검수자 : USER 
               .anyRequest().authenticated() 
 </code></pre> 

 2. Swagger 사용 
 * 설정 파일 위치 : common/config/SwaggerConfig.java (이미 설정되어 있으므로 따로 추가사항 없음) 
 * 접속 URL : http://localhost:18080/swagger-ui/index.html 
 login-controller 에서 로그인 후, 응답 토큰을 우상단 Authorized 버튼 클릭해서 입력하면 인증 가능 

 3. Request URL Naming 
 * RESTful API 기반 : https://restfulapi.net/resource-naming/ 
 * 1 Depth : 대메뉴(ex, project, user 등등) 
 <pre>http://api.example.com/user-management/users 
 http://api.example.com/user-management/users/{id}</pre> 대메뉴