Skip to content

Commit 83963de

Browse files
committed
fix: remove swager user acess on app
1 parent 2ced82e commit 83963de

3 files changed

Lines changed: 6 additions & 5 deletions

File tree

src/main/java/com/github/throyer/common/springboot/configurations/SpringSecurityConfiguration.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import static org.springframework.http.HttpMethod.POST;
1919
import static org.springframework.security.config.http.SessionCreationPolicy.STATELESS;
2020

21+
import java.util.List;
2122
import java.util.Optional;
2223
import java.util.stream.Stream;
2324

@@ -80,7 +81,7 @@ protected void globalConfiguration(
8081
.passwordEncoder(ENCODER)
8182
.withUser(username)
8283
.password(ENCODER.encode(password))
83-
.authorities("SWAGGER");
84+
.authorities(List.of());
8485
}
8586

8687

@@ -133,7 +134,7 @@ public SecurityFilterChain app(HttpSecurity http) throws Exception {
133134
.antMatchers(POST, "/app/register", "/app/recovery/**")
134135
.permitAll()
135136
.anyRequest()
136-
.authenticated()
137+
.hasAuthority("USER")
137138
.and()
138139
.csrf()
139140
.disable()

src/main/resources/templates/app/fragments/me.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
<h5 class="modal-title"><i class="fas fa-user-alt"></i> About me</h5>
66
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
77
</div>
8-
<div class="modal-body py-0" sec:authorize="isAuthenticated()" th:object="${#authentication.principal}">
8+
<div class="modal-body py-0" sec:authorize="hasAnyAuthority('USER', 'ADM')" th:object="${#authentication.principal}">
99
<p>
1010
<span class="fs-3">Name: </span>
11-
<span class="fs-5 fw-light" th:if="*{name}" th:text="*{name}"></span>
11+
<span class="fs-5 fw-light" th:text="*{name}"></span>
1212
</p>
1313
<p>
1414
<span class="fs-3">Roles: </span>

src/main/resources/templates/app/fragments/navbar.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
Show more
6969
</a>
7070
<ul class="dropdown-menu border-0 shadow bg-light animate slideIn" aria-labelledby="show-more">
71-
<li>
71+
<li sec:authorize="hasAnyAuthority('USER', 'ADM')">
7272
<a href="#" data-bs-toggle="modal" data-bs-target="#me" class="dropdown-item">
7373
<i class="fas fa-user-circle"></i>
7474
Me

0 commit comments

Comments
 (0)