Skip to content

Commit 8b1515e

Browse files
authored
Merge pull request #292 from sixwaaaay/condition
feat: add conditional openapi document
2 parents cb10f12 + bcea961 commit 8b1515e

File tree

4 files changed

+38
-4
lines changed

4 files changed

+38
-4
lines changed

.github/workflows/comment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ jobs:
6969
token: ${{ secrets.CODECOV_TOKEN }}
7070

7171
- name: Build Binary Executable
72-
run: mvn clean && mvn -Pnative -Pproduction native:compile -DskipTests
72+
run: mvn clean && mvn -Pnative -Pproduction native:compile -DskipTests -P!openapi
7373

7474
- name: Upload build artifacts
7575
run: |

graal/pom.xml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
~ limitations under the License.
1313
-->
1414

15-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
16-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
15+
<project xmlns="http://maven.apache.org/POM/4.0.0"
16+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
1717
<modelVersion>4.0.0</modelVersion>
1818
<parent>
1919
<groupId>org.springframework.boot</groupId>
@@ -194,5 +194,19 @@
194194
</plugin>
195195
</plugins>
196196
</build>
197-
197+
<profiles>
198+
<profile>
199+
<id>openapi</id>
200+
<activation>
201+
<activeByDefault>true</activeByDefault>
202+
</activation>
203+
<dependencies>
204+
<dependency>
205+
<groupId>org.springdoc</groupId>
206+
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
207+
<version>2.3.0</version>
208+
</dependency>
209+
</dependencies>
210+
</profile>
211+
</profiles>
198212
</project>

graal/src/main/java/io/sixwaaaay/sharingcomment/config/SecurityConfig.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@
2929
@Configuration
3030
public class SecurityConfig {
3131

32+
33+
/**
34+
* configure user detail service
35+
*
36+
* @return user detail service
37+
*/
3238
@Bean
3339
UserDetailsService emptyDetailsService() {
3440
return username -> {
@@ -37,6 +43,13 @@ UserDetailsService emptyDetailsService() {
3743
}
3844

3945

46+
/**
47+
* configure security filter chain
48+
*
49+
* @param http http security builder
50+
* @param tokenParser token parser
51+
* @return security filter chain
52+
*/
4053
@Bean
4154
@SneakyThrows
4255
public SecurityFilterChain filterChain(HttpSecurity http, TokenParser tokenParser) {
@@ -55,8 +68,12 @@ public SecurityFilterChain filterChain(HttpSecurity http, TokenParser tokenParse
5568
"/comments/main",
5669
"/comments/reply"
5770
).permitAll()
71+
.requestMatchers(HttpMethod.GET, "/api*")
72+
.permitAll()
5873
).addFilterBefore(new ServiceInterceptor(tokenParser), UsernamePasswordAuthenticationFilter.class)
74+
/* disable default session management */
5975
.sessionManagement(smc -> smc.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
76+
/* disable default csrf protection */
6077
.csrf(AbstractHttpConfigurer::disable);
6178
return http.build();
6279
}

graal/src/main/resources/application.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ management:
4949
version: 1.0.0-snapshot
5050
cache:
5151
ttl: 5 # 10 seconds
52+
springdoc:
53+
api-docs:
54+
path: /api-docs
5255
service:
5356
vote:
5457
enabled: true

0 commit comments

Comments
 (0)