Skip to content

Commit d075e24

Browse files
committed
BAEL-1917 spring security login page with react
1 parent 7b68989 commit d075e24

27 files changed

Lines changed: 12329 additions & 0 deletions

‎.travis.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ addons:
1717
- oracle-java8-installer
1818

1919
cache:
20+
timeout: 900
2021
directories:
2122
- .autoconf
2223
- $HOME/.m2

‎spring-security-react/.gitignore‎

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
# Created by .ignore support plugin (hsz.mobi)
2+
### JetBrains template
3+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
4+
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
5+
6+
# User-specific stuff:
7+
.idea
8+
9+
# CMake
10+
cmake-build-debug/
11+
cmake-build-release/
12+
13+
## File-based project format:
14+
*.iws
15+
16+
## Plugin-specific files:
17+
18+
# IntelliJ
19+
out/
20+
21+
# mpeltonen/sbt-idea plugin
22+
.idea_modules/
23+
24+
# JIRA plugin
25+
atlassian-ide-plugin.xml
26+
27+
# Crashlytics plugin (for Android Studio and IntelliJ)
28+
com_crashlytics_export_strings.xml
29+
crashlytics.properties
30+
crashlytics-build.properties
31+
fabric.properties
32+
### Eclipse template
33+
34+
.metadata
35+
bin/
36+
tmp/
37+
*.tmp
38+
*.bak
39+
*.swp
40+
*~.nib
41+
local.properties
42+
.settings/
43+
.loadpath
44+
.recommenders
45+
46+
# External tool builders
47+
.externalToolBuilders/
48+
49+
# Locally stored "Eclipse launch configurations"
50+
*.launch
51+
52+
# PyDev specific (Python IDE for Eclipse)
53+
*.pydevproject
54+
55+
# CDT-specific (C/C++ Development Tooling)
56+
.cproject
57+
58+
# CDT- autotools
59+
.autotools
60+
61+
# Java annotation processor (APT)
62+
.factorypath
63+
64+
# PDT-specific (PHP Development Tools)
65+
.buildpath
66+
67+
# sbteclipse plugin
68+
.target
69+
70+
# Tern plugin
71+
.tern-project
72+
73+
# TeXlipse plugin
74+
.texlipse
75+
76+
# STS (Spring Tool Suite)
77+
.springBeans
78+
79+
# Code Recommenders
80+
.recommenders/
81+
82+
# Scala IDE specific (Scala & Java development for Eclipse)
83+
.cache-main
84+
.scala_dependencies
85+
.worksheet
86+
### Maven template
87+
target/
88+
pom.xml.tag
89+
pom.xml.releaseBackup
90+
pom.xml.versionsBackup
91+
pom.xml.next
92+
release.properties
93+
dependency-reduced-pom.xml
94+
buildNumber.properties
95+
.mvn/timing.properties
96+
97+
# Avoid ignoring Maven wrapper jar file (.jar files are usually ignored)
98+
!/.mvn/wrapper/maven-wrapper.jar
99+
### Java template
100+
# Compiled class file
101+
*.class
102+
103+
# Log file
104+
*.log
105+
106+
# BlueJ files
107+
*.ctxt
108+
109+
# Mobile Tools for Java (J2ME)
110+
.mtj.tmp/
111+
112+
# Package Files #
113+
*.jar
114+
*.war
115+
*.ear
116+
*.zip
117+
*.tar.gz
118+
*.rar
119+
120+
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
121+
hs_err_pid*

‎spring-security-react/README.md‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
=========
2+
3+
## Spring Security React Example Project
4+
5+
###The Course
6+
7+
The "Learn Spring Security" Classes: http://github.learnspringsecurity.com
8+
9+
### Relevant Articles:
10+
11+
### Build the Project
12+
13+
```
14+
mvn clean install
15+
```

‎spring-security-react/pom.xml‎

Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<artifactId>spring-security-react</artifactId>
5+
<version>0.1-SNAPSHOT</version>
6+
7+
<name>spring-security-react</name>
8+
<packaging>war</packaging>
9+
10+
<parent>
11+
<groupId>com.baeldung</groupId>
12+
<artifactId>parent-spring-4</artifactId>
13+
<version>0.0.1-SNAPSHOT</version>
14+
<relativePath>../parent-spring-4</relativePath>
15+
</parent>
16+
17+
<dependencies>
18+
19+
<!-- Spring Security -->
20+
21+
<dependency>
22+
<groupId>org.springframework.security</groupId>
23+
<artifactId>spring-security-web</artifactId>
24+
<version>${org.springframework.security.version}</version>
25+
</dependency>
26+
<dependency>
27+
<groupId>org.springframework.security</groupId>
28+
<artifactId>spring-security-config</artifactId>
29+
<version>${org.springframework.security.version}</version>
30+
</dependency>
31+
<dependency>
32+
<groupId>org.springframework.security</groupId>
33+
<artifactId>spring-security-taglibs</artifactId>
34+
<version>${org.springframework.security.version}</version>
35+
</dependency>
36+
37+
<!-- Spring -->
38+
39+
<dependency>
40+
<groupId>org.springframework</groupId>
41+
<artifactId>spring-core</artifactId>
42+
<version>${org.springframework.version}</version>
43+
</dependency>
44+
<dependency>
45+
<groupId>org.springframework</groupId>
46+
<artifactId>spring-context</artifactId>
47+
<version>${org.springframework.version}</version>
48+
</dependency>
49+
<dependency>
50+
<groupId>org.springframework</groupId>
51+
<artifactId>spring-beans</artifactId>
52+
<version>${org.springframework.version}</version>
53+
</dependency>
54+
<dependency>
55+
<groupId>org.springframework</groupId>
56+
<artifactId>spring-aop</artifactId>
57+
<version>${org.springframework.version}</version>
58+
</dependency>
59+
60+
<dependency>
61+
<groupId>org.springframework</groupId>
62+
<artifactId>spring-web</artifactId>
63+
<version>${org.springframework.version}</version>
64+
</dependency>
65+
<dependency>
66+
<groupId>org.springframework</groupId>
67+
<artifactId>spring-webmvc</artifactId>
68+
<version>${org.springframework.version}</version>
69+
</dependency>
70+
71+
<!-- web -->
72+
73+
<dependency>
74+
<groupId>javax.servlet</groupId>
75+
<artifactId>javax.servlet-api</artifactId>
76+
<version>${javax.servlet.version}</version>
77+
<scope>provided</scope>
78+
</dependency>
79+
<dependency>
80+
<groupId>javax.servlet</groupId>
81+
<artifactId>jstl</artifactId>
82+
<version>${jstl.version}</version>
83+
<scope>runtime</scope>
84+
</dependency>
85+
86+
</dependencies>
87+
88+
<build>
89+
<finalName>spring-security-react</finalName>
90+
<resources>
91+
<resource>
92+
<directory>src/main/resources</directory>
93+
<filtering>true</filtering>
94+
</resource>
95+
</resources>
96+
97+
<plugins>
98+
99+
<plugin>
100+
<groupId>org.apache.maven.plugins</groupId>
101+
<artifactId>maven-war-plugin</artifactId>
102+
<version>${maven-war-plugin.version}</version>
103+
<configuration>
104+
<warSourceExcludes>
105+
WEB-INF/view/react/node/**,
106+
WEB-INF/view/react/node_modules/**,
107+
WEB-INF/view/react/public/**,
108+
WEB-INF/view/react/src/**,
109+
WEB-INF/view/react/*
110+
</warSourceExcludes>
111+
</configuration>
112+
</plugin>
113+
114+
<plugin>
115+
<groupId>com.github.eirslett</groupId>
116+
<artifactId>frontend-maven-plugin</artifactId>
117+
<version>${frontend-maven-plugin.version}</version>
118+
<configuration>
119+
<nodeVersion>${node.version}</nodeVersion>
120+
<npmVersion>${npm.version}</npmVersion>
121+
<workingDirectory>src/main/webapp/WEB-INF/view/react</workingDirectory>
122+
</configuration>
123+
<executions>
124+
<execution>
125+
<id>install node and npm</id>
126+
<goals>
127+
<goal>install-node-and-npm</goal>
128+
</goals>
129+
</execution>
130+
<execution>
131+
<id>npm install</id>
132+
<goals>
133+
<goal>npm</goal>
134+
</goals>
135+
</execution>
136+
<execution>
137+
<id>npm run build</id>
138+
<goals>
139+
<goal>npm</goal>
140+
</goals>
141+
<configuration>
142+
<arguments>run build</arguments>
143+
</configuration>
144+
</execution>
145+
</executions>
146+
</plugin>
147+
148+
<plugin>
149+
<groupId>org.eclipse.jetty</groupId>
150+
<artifactId>jetty-maven-plugin</artifactId>
151+
<version>9.4.11.v20180605</version>
152+
</plugin>
153+
154+
</plugins>
155+
156+
</build>
157+
158+
<properties>
159+
<!-- Spring -->
160+
<org.springframework.version>4.3.6.RELEASE</org.springframework.version>
161+
<org.springframework.security.version>4.2.1.RELEASE</org.springframework.security.version>
162+
163+
<!-- various -->
164+
<javax.servlet.version>3.1.0</javax.servlet.version>
165+
<jstl.version>1.2</jstl.version>
166+
167+
<!-- util -->
168+
<guava.version>19.0</guava.version>
169+
<commons-lang3.version>3.5</commons-lang3.version>
170+
171+
<!-- Maven plugins -->
172+
<maven-war-plugin.version>2.6</maven-war-plugin.version>
173+
<maven-resources-plugin.version>2.7</maven-resources-plugin.version>
174+
<frontend-maven-plugin.version>1.6</frontend-maven-plugin.version>
175+
<jetty.version>9.4.11.v20180605</jetty.version>
176+
177+
<!-- frontend -->
178+
<node.version>v8.11.3</node.version>
179+
<npm.version>6.1.0</npm.version>
180+
181+
</properties>
182+
183+
</project>
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package org.baeldung.spring;
2+
3+
import org.springframework.context.annotation.Bean;
4+
import org.springframework.context.annotation.Configuration;
5+
import org.springframework.web.servlet.ViewResolver;
6+
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
7+
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
8+
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
9+
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
10+
import org.springframework.web.servlet.view.InternalResourceViewResolver;
11+
import org.springframework.web.servlet.view.JstlView;
12+
13+
@EnableWebMvc
14+
@Configuration
15+
public class MvcConfig extends WebMvcConfigurerAdapter {
16+
17+
public MvcConfig() {
18+
super();
19+
}
20+
21+
// API
22+
23+
@Override
24+
public void addViewControllers(final ViewControllerRegistry registry) {
25+
super.addViewControllers(registry);
26+
27+
registry.addViewController("/anonymous.html");
28+
29+
registry.addViewController("/login.html");
30+
registry.addViewController("/homepage.html");
31+
registry.addViewController("/admin/adminpage.html");
32+
registry.addViewController("/accessDenied");
33+
}
34+
35+
@Override
36+
public void addResourceHandlers(ResourceHandlerRegistry registry) {
37+
registry.addResourceHandler("/static/**").addResourceLocations("/WEB-INF/view/react/build/static/");
38+
39+
registry.addResourceHandler("/*.js").addResourceLocations("/WEB-INF/view/react/build/");
40+
registry.addResourceHandler("/*.json").addResourceLocations("/WEB-INF/view/react/build/");
41+
registry.addResourceHandler("/*.ico").addResourceLocations("/WEB-INF/view/react/build/");
42+
registry.addResourceHandler("/index.html").addResourceLocations("/WEB-INF/view/react/build/index.html");
43+
}
44+
45+
@Bean
46+
public ViewResolver viewResolver() {
47+
final InternalResourceViewResolver bean = new InternalResourceViewResolver();
48+
49+
bean.setViewClass(JstlView.class);
50+
bean.setPrefix("/WEB-INF/view/");
51+
bean.setSuffix(".jsp");
52+
53+
return bean;
54+
}
55+
}

0 commit comments

Comments
 (0)