-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from Petrovich-A/develop
Develop
- Loading branch information
Showing
71 changed files
with
1,215 additions
and
689 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
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
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
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,16 @@ | ||
package by.petrovich.eshop; | ||
|
||
public class PageName { | ||
public static final String HOME_PAGE = "home"; | ||
public static final String CATEGORY_PAGE = "category"; | ||
public static final String LOGIN_PAGE = "login"; | ||
public static final String REGISTRATION_PAGE = "registration"; | ||
public static final String PRODUCT_PAGE = "product"; | ||
public static final String PROFILE_PAGE = "profile"; | ||
public static final String CART_PAGE = "cart"; | ||
public static final String ORDER_HISTORY_PAGE = "order_history"; | ||
public static final String ORDER_PAGE = "order"; | ||
public static final String ADMIN_PAGE = "admin"; | ||
public static final String ERROR_PAGE = "error"; | ||
|
||
} |
This file was deleted.
Oops, something went wrong.
50 changes: 50 additions & 0 deletions
50
src/main/java/by/petrovich/eshop/config/WebSecurityConfig.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,50 @@ | ||
package by.petrovich.eshop.config; | ||
|
||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.ComponentScan; | ||
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.crypto.bcrypt.BCryptPasswordEncoder; | ||
import org.springframework.security.crypto.password.PasswordEncoder; | ||
import org.springframework.security.web.SecurityFilterChain; | ||
import org.springframework.security.web.util.matcher.AntPathRequestMatcher; | ||
|
||
@Configuration | ||
@EnableWebSecurity | ||
@ComponentScan(basePackages = "by") | ||
public class WebSecurityConfig { | ||
|
||
@Bean | ||
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { | ||
http | ||
.csrf().disable() | ||
.authorizeHttpRequests(requests -> requests | ||
.requestMatchers("/javaScript/**", "/img/**", "/CSS/**").permitAll() | ||
.requestMatchers("/", "/home", "/registration", "/users/registrate", "/login").permitAll() | ||
.requestMatchers("/admin").hasRole("ADMIN") | ||
.anyRequest().authenticated() | ||
) | ||
.formLogin(form -> form | ||
.loginPage("/login") | ||
.loginProcessingUrl("/login") | ||
.usernameParameter("username") | ||
.passwordParameter("password") | ||
.defaultSuccessUrl("/home", true) | ||
.permitAll() | ||
) | ||
.logout(logout -> logout | ||
.logoutRequestMatcher(new AntPathRequestMatcher("/logout")) | ||
.invalidateHttpSession(true) | ||
.clearAuthentication(true) | ||
.permitAll() | ||
); | ||
return http.build(); | ||
} | ||
|
||
@Bean | ||
public PasswordEncoder passwordEncoder() { | ||
return new BCryptPasswordEncoder(); | ||
} | ||
|
||
} |
35 changes: 0 additions & 35 deletions
35
src/main/java/by/petrovich/eshop/controllers/AuthController.java
This file was deleted.
Oops, something went wrong.
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
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
Oops, something went wrong.