-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/main/java/com/endlesshorses/oot/swagger/SecurityConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.endlesshorses.oot.swagger; | ||
|
||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.security.config.annotation.web.builders.HttpSecurity; | ||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; | ||
import org.springframework.security.web.SecurityFilterChain; | ||
|
||
@Configuration | ||
@EnableWebSecurity | ||
public class SecurityConfig { | ||
private static final String[] AUTH_WHITELIST = { | ||
"/api/**", "/graphiql", "/graphql", | ||
"/swagger-ui/**", "/api-docs", "/swagger-ui-custom.html", | ||
"/v3/api-docs/**", "/api-docs/**", "/swagger-ui.html" | ||
}; | ||
|
||
@Bean | ||
public SecurityFilterChain filterChain(HttpSecurity httpSecurity) throws Exception { | ||
return httpSecurity | ||
.authorizeHttpRequests( | ||
authorize -> authorize | ||
.shouldFilterAllDispatcherTypes(false) | ||
.requestMatchers(AUTH_WHITELIST) | ||
.permitAll() | ||
.anyRequest() | ||
.authenticated() | ||
) | ||
.httpBasic().disable() | ||
.formLogin().disable() | ||
.cors().disable() | ||
.csrf().disable() | ||
.build(); | ||
} | ||
|
||
} |
48 changes: 48 additions & 0 deletions
48
src/main/java/com/endlesshorses/oot/swagger/SwaggerConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package com.endlesshorses.oot.swagger; | ||
|
||
import io.swagger.v3.oas.models.Components; | ||
import io.swagger.v3.oas.models.OpenAPI; | ||
import io.swagger.v3.oas.models.info.Info; | ||
import org.springdoc.core.models.GroupedOpenApi; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
public class SwaggerConfig { | ||
|
||
@Bean | ||
public GroupedOpenApi getItemApi() { | ||
|
||
return GroupedOpenApi | ||
.builder() | ||
.group("item") | ||
.pathsToMatch("/api/item/**") | ||
.build(); | ||
} | ||
|
||
@Bean | ||
public GroupedOpenApi getMemberApi() { | ||
|
||
return GroupedOpenApi | ||
.builder() | ||
.group("member") | ||
.pathsToMatch("/api/member/**") | ||
.build(); | ||
|
||
} | ||
|
||
@Bean | ||
public OpenAPI getOpenApi() { | ||
|
||
return new OpenAPI().components(new Components()) | ||
.info(getInfo()); | ||
|
||
} | ||
|
||
private Info getInfo() { | ||
return new Info() | ||
.version("1.0.0") | ||
.description("COMMERCE REST API DOC") | ||
.title("COMMERCE"); | ||
} | ||
} |