Skip to content

Commit

Permalink
Updating to latest jquery and bootstrap, also other dependencies, the…
Browse files Browse the repository at this point in the history
…n fixing some issues on security config
  • Loading branch information
surajcm committed Aug 2, 2023
1 parent b7ebf7e commit c08574a
Show file tree
Hide file tree
Showing 32 changed files with 98 additions and 86 deletions.
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ buildscript {
plugins {
id 'java'
id 'idea'
id 'org.springframework.boot' version '3.1.1'
id 'io.spring.dependency-management' version '1.1.0'
id 'net.ltgt.errorprone' version '3.0.1'
id 'org.springframework.boot' version '3.1.2'
id 'io.spring.dependency-management' version '1.1.2'
id 'net.ltgt.errorprone' version '3.1.0'
//id 'com.github.spotbugs' version '1.6.8' apply false
id 'de.aaschmid.cpd' version '3.3'
id "org.sonarqube" version "4.2.0.3129"
id "org.sonarqube" version "4.3.0.3225"
}
group = 'com.poseidon'
version = '0.0.1-SNAPSHOT'
Expand Down
1 change: 1 addition & 0 deletions config/checkstyle/suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,6 @@ WHAT AND WHY CHECKS SUPPRESSED
<suppress files="UserController.java" checks="IllegalCatch"/>
<suppress files="UserDAO.java" checks="IllegalCatch"/>
<suppress files="WebSecurityConfig.java" checks="MethodLength"/>
<suppress files="WebSecurityConfig.java" checks="IllegalCatch"/>
<suppress files="CustomerServiceTest.java" checks="MethodLength"/>
</suppressions>
2 changes: 1 addition & 1 deletion gradle/dependencies.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

dependencies {
errorprone("com.google.errorprone:error_prone_core:2.19.1")
errorprone("com.google.errorprone:error_prone_core:2.20.0")
errorproneJavac('com.google.errorprone:javac:9+181-r4173-1')

implementation("org.springframework.boot:spring-boot-starter-web")
Expand Down
2 changes: 1 addition & 1 deletion gradle/staticCodeAnalysis.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ apply plugin: 'jacoco'
//apply plugin: 'com.github.spotbugs'

checkstyle {
toolVersion = '10.12.1'
toolVersion = '10.12.2'
ignoreFailures = false
maxWarnings = 0
checkstyleMain {
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
63 changes: 40 additions & 23 deletions src/main/java/com/poseidon/init/WebSecurityConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
import org.springframework.security.config.annotation.web.configurers.HeadersConfigurer;
import org.springframework.security.config.annotation.web.configurers.LogoutConfigurer;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.web.SecurityFilterChain;
import org.springframework.security.web.servlet.util.matcher.MvcRequestMatcher;
import org.springframework.web.servlet.handler.HandlerMappingIntrospector;

@Configuration
@EnableWebSecurity
Expand All @@ -28,37 +32,50 @@ public BCryptPasswordEncoder bcryptPasswordEncoder() {
}

@Bean
public SecurityFilterChain filterChain(final HttpSecurity http) throws Exception {
public SecurityFilterChain filterChain(final HttpSecurity http,
final HandlerMappingIntrospector introspect) throws Exception {
http.csrf(AbstractHttpConfigurer::disable);
http.authorizeHttpRequests(auth -> auth
.requestMatchers("/resources/**",
"/registration",
"/css/**", "/js/**", "/img/**",
"/h2-console/**",
"/console/**").permitAll()
.anyRequest().authenticated()
);
http.formLogin()
.loginPage("/login")
.defaultSuccessUrl("/", true).permitAll().and()
.headers()
.frameOptions().sameOrigin().and()
.logout()
.permitAll().and()
.requiresChannel()
.requestMatchers(r -> r.getHeader("X-Forwarded-Proto") != null)
.requiresSecure();
var mvcMatcherBuilder = new MvcRequestMatcher.Builder(introspect);
for (var paths: matchingPaths()) {
http.authorizeHttpRequests(auth -> auth
.requestMatchers(mvcMatcherBuilder.pattern(paths)).permitAll()
);
}
http.authorizeHttpRequests(auth -> auth.anyRequest().authenticated());

http.formLogin((formLogin) -> {
try {
formLogin.loginPage("/login")
.defaultSuccessUrl("/", true).permitAll();
} catch (Exception ex) {
//todo : clean up
throw new RuntimeException(ex);
}
});
http.headers((headers) ->
headers.frameOptions(HeadersConfigurer.FrameOptionsConfig::sameOrigin));
http.logout(LogoutConfigurer::permitAll);
http.requiresChannel(c -> c.requestMatchers(r ->
r.getHeader("X-Forwarded-Proto") != null).requiresSecure());
return http.build();
}

@Bean
public AuthenticationManager authManager(final HttpSecurity http,
final BCryptPasswordEncoder bCryptPasswordEncoder)
throws Exception {
return http.getSharedObject(AuthenticationManagerBuilder.class)
var managerBuilder = http.getSharedObject(AuthenticationManagerBuilder.class)
.userDetailsService(userDetailsService)
.passwordEncoder(bCryptPasswordEncoder)
.and()
.build();
.passwordEncoder(bCryptPasswordEncoder);
return managerBuilder.and().build();
}

private String[] matchingPaths() {
return new String[] {"/resources/**",
"/registration",
"/css/**", "/js/**", "/img/**",
"/h2-console/**",
"/console/**"
};
}
}

Large diffs are not rendered by default.

Large diffs are not rendered by default.

7 changes: 0 additions & 7 deletions src/main/resources/static/css/core/bootstrap-5.min.css

This file was deleted.

2 changes: 0 additions & 2 deletions src/main/resources/static/css/core/bootstrap.min.css.map

This file was deleted.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

7 changes: 0 additions & 7 deletions src/main/resources/static/js/core/bootstrap-5.min.js

This file was deleted.

1 change: 0 additions & 1 deletion src/main/resources/static/js/core/bootstrap.min.js.map

This file was deleted.

4 changes: 0 additions & 4 deletions src/main/resources/static/js/core/jquery-3.2.1.min.js

This file was deleted.

2 changes: 0 additions & 2 deletions src/main/resources/static/js/core/jquery-3.3.1.slim.min.js

This file was deleted.

2 changes: 2 additions & 0 deletions src/main/resources/static/js/core/jquery-3.7.0.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/main/resources/templates/ErrorPage.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<meta name="description" content="">
<meta name="author" content="Suraj">
<link rel="shortcut icon" href="/img/Poseidon_Ico.ico" />
<link rel="stylesheet" href="/css/core/bootstrap-5.min.css" type="text/css" />
<link rel="stylesheet" href="/css/core/bootstrap-5.3.1/bootstrap.min.css" type="text/css" />
<link rel="stylesheet" href="/css/custom.css" type="text/css" />
<link rel="stylesheet" href="/css/core/flag-icon.min.css" type="text/css" />
<title>Error Page</title>
Expand All @@ -25,6 +25,6 @@
</section>
</form>
<script src="/js/core/popper.min.js" type="text/javascript"></script>
<script src="/js/core/bootstrap-5.min.js" type="text/javascript"></script>
<script src="/js/core/bootstrap-5.3.1/bootstrap.min.js" type="text/javascript"></script>
</body>
</html>
4 changes: 2 additions & 2 deletions src/main/resources/templates/MainPage.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<!--meta name="_csrf" th:content="${_csrf.token}"/>
<meta name="_csrf_header" th:content="${_csrf.headerName}"/-->
<link rel="shortcut icon" href="/img/Poseidon_Ico.ico" />
<link rel="stylesheet" href="/css/core/bootstrap-5.min.css" type="text/css" />
<link rel="stylesheet" href="/css/core/bootstrap-5.3.1/bootstrap.min.css" type="text/css" />
<link rel="stylesheet" href="/css/custom.css" type="text/css" />
<link rel="stylesheet" href="/css/core/flag-icon.min.css" type="text/css" />
<title>Welcome</title>
Expand All @@ -32,6 +32,6 @@
</section>
</form>
<script src="/js/core/popper.min.js" type="text/javascript"></script>
<script src="/js/core/bootstrap-5.min.js" type="text/javascript"></script>
<script src="/js/core/bootstrap-5.3.1/bootstrap.min.js" type="text/javascript"></script>
</body>
</html>
4 changes: 2 additions & 2 deletions src/main/resources/templates/company/companyDetails.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<meta name="description" content="">
<meta name="author" content="Suraj">
<link rel="shortcut icon" href="/img/Poseidon_Ico.ico" />
<link rel="stylesheet" href="/css/core/bootstrap-5.min.css" type="text/css" />
<link rel="stylesheet" href="/css/core/bootstrap-5.3.1/bootstrap.min.css" type="text/css" />
<link rel="stylesheet" href="/css/custom.css" type="text/css" />
<link rel="stylesheet" href="/css/core/flag-icon.min.css" type="text/css" />
<title>Terms And Company details</title>
Expand Down Expand Up @@ -81,6 +81,6 @@
</div>
</div>
<script src="/js/core/popper.min.js" type="text/javascript"></script>
<script src="/js/core/bootstrap-5.min.js" type="text/javascript"></script>
<script src="/js/core/bootstrap-5.3.1/bootstrap.min.js" type="text/javascript"></script>
</body>
</html>
4 changes: 2 additions & 2 deletions src/main/resources/templates/customer/CustomerList.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<meta name="_csrf" content="${_csrf.token}"/>
<meta name="_csrf_header" content="${_csrf.headerName}"/>
<link rel="shortcut icon" href="/img/Poseidon_Ico.ico" />
<link rel="stylesheet" href="/css/core/bootstrap-5.min.css" type="text/css" />
<link rel="stylesheet" href="/css/core/bootstrap-5.3.1/bootstrap.min.css" type="text/css" />
<link rel="stylesheet" href="/css/custom.css" type="text/css" />
<link rel="stylesheet" href="/css/core/flag-icon.min.css" type="text/css" />
<title>Customer List</title>
Expand Down Expand Up @@ -188,6 +188,6 @@ <h5 class="modal-title">Customer Details</h5>
</div>
</form>
<script src="/js/core/popper.min.js" type="text/javascript"></script>
<script src="/js/core/bootstrap-5.min.js" type="text/javascript"></script>
<script src="/js/core/bootstrap-5.3.1/bootstrap.min.js" type="text/javascript"></script>
</body>
</html>
4 changes: 2 additions & 2 deletions src/main/resources/templates/invoice/ListInvoice.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<meta name="_csrf" content="${_csrf.token}"/>
<meta name="_csrf_header" content="${_csrf.headerName}"/>
<link rel="shortcut icon" href="/img/Poseidon_Ico.ico" />
<link rel="stylesheet" href="/css/core/bootstrap-5.min.css" type="text/css" />
<link rel="stylesheet" href="/css/core/bootstrap-5.3.1/bootstrap.min.css" type="text/css" />
<link rel="stylesheet" href="/css/custom.css" type="text/css" />
<link rel="stylesheet" href="/css/core/flag-icon.min.css" type="text/css" />
<title>Invoice List</title>
Expand Down Expand Up @@ -198,6 +198,6 @@ <h5 class="modal-title">Edit Invoice</h5>
</div>
</form>
<script src="/js/core/popper.min.js" type="text/javascript"></script>
<script src="/js/core/bootstrap-5.min.js" type="text/javascript"></script>
<script src="/js/core/bootstrap-5.3.1/bootstrap.min.js" type="text/javascript"></script>
</body>
</html>
4 changes: 2 additions & 2 deletions src/main/resources/templates/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<link rel="shortcut icon" href="/img/Poseidon_Ico.ico" >
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Log In</title>
<link rel="stylesheet" href="/css/core/bootstrap-5.min.css" type="text/css"/>
<link rel="stylesheet" href="/css/core/bootstrap-5.3.1/bootstrap.min.css" type="text/css"/>
<link rel="stylesheet" href="/css/logInStyles.css" type="text/css" />
<script type="text/javascript">
function popupForget() {
Expand Down Expand Up @@ -86,6 +86,6 @@ <h5 class="modal-title" id="exampleModalLabel">Forget Password?</h5>
</div>
</div>
</div>
<script src="/js/core/bootstrap-5.min.js" type="text/javascript"></script>
<script src="/js/core/bootstrap-5.3.1/bootstrap.min.js" type="text/javascript"></script>
</body>
</html>
4 changes: 2 additions & 2 deletions src/main/resources/templates/make/MakeList.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<meta name="_csrf" content="${_csrf.token}"/>
<meta name="_csrf_header" content="${_csrf.headerName}"/>
<link rel="shortcut icon" href="/img/Poseidon_Ico.ico" />
<link rel="stylesheet" href="/css/core/bootstrap-5.min.css" type="text/css" />
<link rel="stylesheet" href="/css/core/bootstrap-5.3.1/bootstrap.min.css" type="text/css" />
<link rel="stylesheet" href="/css/custom.css" type="text/css" />
<link rel="stylesheet" href="/css/core/flag-icon.min.css" type="text/css" />
<title>Make List</title>
Expand Down Expand Up @@ -141,6 +141,6 @@ <h5 class="modal-title">Edit Make</h5>
</div>
</form>
<script src="/js/core/popper.min.js" type="text/javascript"></script>
<script src="/js/core/bootstrap-5.min.js" type="text/javascript"></script>
<script src="/js/core/bootstrap-5.3.1/bootstrap.min.js" type="text/javascript"></script>
</body>
</html>
4 changes: 2 additions & 2 deletions src/main/resources/templates/make/ModelList.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<meta name="_csrf" content="${_csrf.token}"/>
<meta name="_csrf_header" content="${_csrf.headerName}"/>
<link rel="shortcut icon" href="/img/Poseidon_Ico.ico" />
<link rel="stylesheet" href="/css/core/bootstrap-5.min.css" type="text/css" />
<link rel="stylesheet" href="/css/core/bootstrap-5.3.1/bootstrap.min.css" type="text/css" />
<link rel="stylesheet" href="/css/custom.css" type="text/css" />
<link rel="stylesheet" href="/css/core/flag-icon.min.css" type="text/css" />
<title>Make and Model List</title>
Expand Down Expand Up @@ -172,6 +172,6 @@ <h5 class="modal-title">Edit Model</h5>
</div>
</form>
<script src="/js/core/popper.min.js" type="text/javascript"></script>
<script src="/js/core/bootstrap-5.min.js" type="text/javascript"></script>
<script src="/js/core/bootstrap-5.3.1/bootstrap.min.js" type="text/javascript"></script>
</body>
</html>
4 changes: 2 additions & 2 deletions src/main/resources/templates/registration.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<meta name="description" content="">
<meta name="author" content="Suraj">
<link rel="shortcut icon" href="/img/Poseidon_Ico.ico" >
<link rel="stylesheet" href="/css/core/bootstrap-5.min.css" type="text/css"/>
<link rel="stylesheet" href="/css/core/bootstrap-5.3.1/bootstrap.min.css" type="text/css"/>
<link rel="stylesheet" href="/css/logInStyles.css" type="text/css" />
<title>Registration</title>
</head>
Expand Down Expand Up @@ -70,6 +70,6 @@ <h1 class="mb-0 h3">Registration</h1>
</div>
</section>
</main>
<script src="/js/core/bootstrap-5.min.js" type="text/javascript"></script>
<script src="/js/core/bootstrap-5.3.1/bootstrap.min.js" type="text/javascript"></script>
</body>
</html>
4 changes: 2 additions & 2 deletions src/main/resources/templates/reports/List.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<meta name="description" content="">
<meta name="author" content="Suraj">
<link rel="shortcut icon" href="/img/Poseidon_Ico.ico" />
<link rel="stylesheet" href="/css/core/bootstrap-5.min.css" type="text/css" />
<link rel="stylesheet" href="/css/core/bootstrap-5.3.1/bootstrap.min.css" type="text/css" />
<link rel="stylesheet" href="/css/custom.css" type="text/css" />
<link rel="stylesheet" href="/css/core/flag-icon.min.css" type="text/css" />
<title>Reports List</title>
Expand Down Expand Up @@ -243,6 +243,6 @@
</div>
</form>
<script src="/js/core/popper.min.js" type="text/javascript"></script>
<script src="/js/core/bootstrap-5.min.js" type="text/javascript"></script>
<script src="/js/core/bootstrap-5.3.1/bootstrap.min.js" type="text/javascript"></script>
</body>
</html>
6 changes: 3 additions & 3 deletions src/main/resources/templates/txs/TransactionList.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<meta name="author" content="Suraj">
<link rel="shortcut icon" href="/img/Poseidon_Ico.ico" />
<link rel="stylesheet" href="/css/jquery-ui.css" type="text/css" />
<link rel="stylesheet" href="/css/core/bootstrap-5.min.css" type="text/css" />
<link rel="stylesheet" href="/css/core/bootstrap-5.3.1/bootstrap.min.css" type="text/css" />
<link rel="stylesheet" href="/css/custom.css" type="text/css" />
<link rel="stylesheet" href="/css/core/flag-icon.min.css" type="text/css" />
<title>Transaction List</title>
Expand Down Expand Up @@ -201,9 +201,9 @@ <h5 class="modal-title">Invoice transaction</h5>
</div>
</div>
</form>
<script src="/js/core/jquery-3.2.1.min.js" type="text/javascript"></script>
<script src="/js/core/jquery-3.7.0.min.js" type="text/javascript"></script>
<script src="/js/core/popper.min.js" type="text/javascript"></script>
<script src="/js/core/bootstrap-5.min.js" type="text/javascript"></script>
<script src="/js/core/bootstrap-5.3.1/bootstrap.min.js" type="text/javascript"></script>
<script src="/js/core/jquery-ui.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/templates/txs/TxnAdd.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<meta name="author" content="Suraj">
<link rel="shortcut icon" href="/img/Poseidon_Ico.ico" />
<link rel="stylesheet" href="/css/jquery-ui.css" type="text/css" />
<link rel="stylesheet" href="/css/core/bootstrap-5.min.css" type="text/css" />
<link rel="stylesheet" href="/css/core/bootstrap-5.3.1/bootstrap.min.css" type="text/css" />
<link rel="stylesheet" href="/css/custom.css" type="text/css" />
<link rel="stylesheet" href="/css/core/flag-icon.min.css" type="text/css" />
<title>Add Transaction</title>
Expand Down Expand Up @@ -186,9 +186,9 @@ <h5 class="modal-title">Find Customer</h5>
</div>
</div>
</form>
<script src="/js/core/jquery-3.2.1.min.js" type="text/javascript"></script>
<script src="/js/core/jquery-3.7.0.min.js" type="text/javascript"></script>
<script src="/js/core/popper.min.js" type="text/javascript"></script>
<script src="/js/core/bootstrap-5.min.js" type="text/javascript"></script>
<script src="/js/core/bootstrap-5.3.1/bootstrap.min.js" type="text/javascript"></script>
<script src="/js/core/jquery-ui.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/templates/txs/TxnEdit.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<meta name="author" content="Suraj">
<link rel="shortcut icon" href="/img/Poseidon_Ico.ico" />
<link rel="stylesheet" href="/css/jquery-ui.css" type="text/css" />
<link rel="stylesheet" href="/css/core/bootstrap-5.min.css" type="text/css" />
<link rel="stylesheet" href="/css/core/bootstrap-5.3.1/bootstrap.min.css" type="text/css" />
<link rel="stylesheet" href="/css/custom.css" type="text/css" />
<link rel="stylesheet" href="/css/core/flag-icon.min.css" type="text/css" />
<title>Edit Transaction</title>
Expand Down Expand Up @@ -211,9 +211,9 @@ <h5 class="modal-title">Add Customer</h5>
</div>
</div>
</form>
<script src="/js/core/jquery-3.2.1.min.js" type="text/javascript"></script>
<script src="/js/core/jquery-3.7.0.min.js" type="text/javascript"></script>
<script src="/js/core/popper.min.js" type="text/javascript"></script>
<script src="/js/core/bootstrap-5.min.js" type="text/javascript"></script>
<script src="/js/core/bootstrap-5.3.1/bootstrap.min.js" type="text/javascript"></script>
<script src="/js/core/jquery-ui.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function()
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/templates/user/PasswordReset.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<meta name="_csrf" content="${_csrf.token}"/>
<meta name="_csrf_header" content="${_csrf.headerName}"/>
<link rel="shortcut icon" href="/img/Poseidon_Ico.ico" />
<link rel="stylesheet" href="/css/core/bootstrap-5.min.css" type="text/css" />
<link rel="stylesheet" href="/css/core/bootstrap-5.3.1/bootstrap.min.css" type="text/css" />
<link rel="stylesheet" href="/css/custom.css" type="text/css" />
<link rel="stylesheet" href="/css/core/flag-icon.min.css" type="text/css" />
<title>Password Reset</title>
Expand Down Expand Up @@ -61,6 +61,6 @@ <h6 class="text-center col-12 mb-0">Reset Password</h6>
</div>
</form>
<script src="/js/core/popper.min.js" type="text/javascript"></script>
<script src="/js/core/bootstrap-5.min.js" type="text/javascript"></script>
<script src="/js/core/bootstrap-5.3.1/bootstrap.min.js" type="text/javascript"></script>
</body>
</html>
Loading

0 comments on commit c08574a

Please sign in to comment.