From 7ab3526d5005516d8781a7721e511a3fa77a3cea Mon Sep 17 00:00:00 2001 From: Zastian Pretorius Date: Mon, 29 Aug 2022 14:14:38 +0100 Subject: [PATCH] added admin page --- .../config/SecurityConfiguration.java | 5 +- .../springboot/web/MainController.java | 5 ++ src/main/resources/templates/admin.html | 45 ++++++++++++++++++ src/main/resources/templates/index.html | 2 + .../config/SecurityConfiguration.class | Bin 5127 -> 5353 bytes .../springboot/web/MainController.class | Bin 699 -> 798 bytes target/classes/templates/index.html | 2 + ...ootSecurityThymeleafApplicationTests.class | Bin 669 -> 669 bytes 8 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 src/main/resources/templates/admin.html diff --git a/src/main/java/net/javaguides/springboot/config/SecurityConfiguration.java b/src/main/java/net/javaguides/springboot/config/SecurityConfiguration.java index 318b463..1417029 100644 --- a/src/main/java/net/javaguides/springboot/config/SecurityConfiguration.java +++ b/src/main/java/net/javaguides/springboot/config/SecurityConfiguration.java @@ -40,7 +40,9 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter { @Override protected void configure(HttpSecurity http) throws Exception { - http.authorizeRequests().antMatchers( + http.authorizeRequests() + .antMatchers("/admin").hasRole("ADMIN") + .antMatchers( "/registration**", "/js/**", "/css/**", @@ -57,6 +59,7 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter { .logoutRequestMatcher(new AntPathRequestMatcher("/logout")) .logoutSuccessUrl("/login?logout") .permitAll(); + } } diff --git a/src/main/java/net/javaguides/springboot/web/MainController.java b/src/main/java/net/javaguides/springboot/web/MainController.java index 21df2df..d7cc127 100644 --- a/src/main/java/net/javaguides/springboot/web/MainController.java +++ b/src/main/java/net/javaguides/springboot/web/MainController.java @@ -15,4 +15,9 @@ public class MainController { public String home() { return "index"; } + + @GetMapping("/admin") + public String admin() { + return "admin"; + } } diff --git a/src/main/resources/templates/admin.html b/src/main/resources/templates/admin.html new file mode 100644 index 0000000..c96d10d --- /dev/null +++ b/src/main/resources/templates/admin.html @@ -0,0 +1,45 @@ + + + + +Registration and Login App + + + + + + + + +
+
+ +
+

The good shit

+ Welcome Admin +
+ + diff --git a/src/main/resources/templates/index.html b/src/main/resources/templates/index.html index 639fb67..6bfc30f 100644 --- a/src/main/resources/templates/index.html +++ b/src/main/resources/templates/index.html @@ -41,6 +41,8 @@

Registration and Login with Spring Boot, Spring Security, Thymeleaf, Hibernate and MySQL

Welcome User + diff --git a/target/classes/net/javaguides/springboot/config/SecurityConfiguration.class b/target/classes/net/javaguides/springboot/config/SecurityConfiguration.class index ab6aabbd11d047c440a45d7f6fa0faa51b9e11a5..8e7539f189f6824b4f8d7d2572773e821b545566 100644 GIT binary patch delta 1184 zcmZqIc&W*C>ff$?3=9k=3`;k1m9mPn=_jV-X6A7*7&Dl#Gnn!)m@$|$GBizo$kH^~ zoz05Hl98cs@l{grz85vj|U3@+LxEL%LY$80;At*fSD~gYt7y85w3w zZsZA>tib9L&B5Tv$iS~(l$xGdTvC)+l9`{UrNzPE%*eo|pH-|6V!JXjuQ;Ei?ORISuh0fFa&~>@Ftd) zWTfVmWF{w;q^5wB1@kb3FoaHyV-IHw=V6Foh@8BeJzXjqWOYt{I>@uJ3~}rX@jMI( z42g^kL6aY{*iYu+5T4w}QOOa@kPNarWimf!9(OE58py14Mh2(JjLZs?xP&I};uI0e zGgY)EvEV7gDa0^ZjD z40R0klNWQZm2PBY;ME6v#vZ0Pm!X-5p@pG!ayCybM=nD<$QRk0Kk!&FF;3sC%|C;Y zWf3Do^5lms$&ye6e7+ zR|MI>0W|>TmVU5diVR91!zS|yY1e}+7GhvwU|^7A;9!tv5MWSXkYG>*8zRQQ#K6EH z1vP_%L5N`j!$bx~24vG%7$z}HW?%+8&53~ttb^6o}uviAmHijIQZ45=b8A>CC%C|FAZeyqsYS_lm zw2h$+$!Bg1f(#4{+6=r5It&I3x(sFvh76VrMhs32#ta?|CJep|rVIfLW(;8r<_s|m z77PgtmJBHjRtyCU)(oY&3^oiE47Ln44E9LDQVS22T83E+v$2KBECvP!W`;T7$e#<2 m5l{%vV_;yI&%nU2fB}?{m>7&17BVbmU}UghSje!1fe`>e!{P=2 delta 1094 zcmaE<*{;EL>ff$?3=9k=40AVfm9o0=>ldY_XBL+fC6;97=V@tiFc>p3u<2(N>x0;) zj127h$;A+kIf#>)o35{=#l>LBV8za0&BI{BV9UtRH2EP*(_{%YD;9f3hQi4YSyCqN zV&hfdVz6UyBfG zT%41io|(tR5Xun7&JfPS5Wx^R`9H@w?oftkkPBiM88V^Tl_pDZX>x}$#DNTtXJl}K ziVIC{;1Xd=aU5mzHobAF?D*{vha5-@w4Yz{bGH(8$2Rz{WAh|o@p_PrVhl_S z3=C3G4IB(Y3>^%e42%rOT3Hyn7`hpl!R~NkU;^vl($?C>Ais@4IUL~=F0hOm11Ezz z*fkKdxu9kEu9)RwCZtYEV;wYM>7 zu*uV-Nq0L7E55+#*o6YjUj6{LvEx{{&t4K`fUs)LKWK>sZ49-&`=DE(3lj0`*w{R|8Yx=_b63vq8ibGj%|#)(TaFfqu0waPMp LTnh>oIR*v*E>j!3 delta 282 zcmbQowwsmf)W2Q(7#J8#7-S}LxiYge@NA5gWt`m17*x;Az{CIo%nXbStPE@nj10UC z3=H}Vj0}tn3=FJV+Zh-)GB7YOG4L@kfTbB2*ctd47#MgU3K#?!1Q{3@7#TPigcz8> znsuR?nT6OlplRhs(#j0dTFt<~Ak4tPz{kMIAi}`NAR5iUSj-^Cz{ntu#XL@Q^90b% X!)lxa0~3QJ*dRegistration and Login with Spring Boot, Spring Security, Thymeleaf, Hibernate and MySQL Welcome User + diff --git a/target/test-classes/net/javaguides/springboot/RegistrationLoginSpringBootSecurityThymeleafApplicationTests.class b/target/test-classes/net/javaguides/springboot/RegistrationLoginSpringBootSecurityThymeleafApplicationTests.class index f0bf0d4bf3bf04e287b3ea5fa9ea859cfdb913fb..44426f2261a02909aebc9c0cd799a4199ddb739f 100644 GIT binary patch delta 17 ZcmbQsI+vB>)W2Q(7#J8#HgZg50suS@1`z-N delta 17 ZcmbQsI+vB>)W2Q(7#JArHgZg50suTg1{(kX