Skip to content

nbibh #98

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 46 commits into
base: lombok
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
0b561fd
Switch order of literals to prevent NullPointerException (#2)
pixeebot[bot] Sep 29, 2023
be95955
Update AdminController.java
BakhshiMoeez Oct 27, 2023
9ea0dfd
remove NO_AUTO_CREATE_USER
Nov 21, 2023
075b7fc
change the id generation strategy
Nov 21, 2023
505f258
add try catch in addUser
Nov 22, 2023
6582c3d
Merge remote-tracking branch 'upstream/master2' into issue-41
Nov 22, 2023
40dfd66
update README
Nov 22, 2023
6c3fc74
removed unecessary forEach in productsUpdate.jsp
Nov 28, 2023
e2dbbb1
Update application.properties
SreelekhaB77 May 29, 2024
546fc71
Update application.properties
SreelekhaB77 May 29, 2024
8d21833
Merge branch 'master2' into master2
NisargPipaliya Jun 6, 2024
f9d654a
Merge pull request #30 from zcarroll4/master2
NisargPipaliya Jun 6, 2024
8313b8b
Create label.yml
NisargPipaliya Jun 6, 2024
b1c712d
Create jenkins file
DanishCh4321 Jun 30, 2024
5ac4351
updated ui of login pages
shubhranshii Jul 2, 2024
bd3eb99
Merge pull request #69 from shubhranshii/master2
jaygajera17 Jul 2, 2024
6610d9d
Merge pull request #66 from DanishCh4321/patch-1
jaygajera17 Jul 2, 2024
327c8be
Update README.md
jaygajera17 Jul 3, 2024
057cfcf
Merge pull request #43 from WangGithub0/issue-41
NisargPipaliya Jul 15, 2024
6f775b6
Merge pull request #49 from kliu57/issue-48
NisargPipaliya Jul 15, 2024
4310c9d
Merge pull request #42 from WangGithub0/issue-37
NisargPipaliya Jul 15, 2024
a6b49b5
Merge pull request #63 from SreelekhaB77/patch-2
NisargPipaliya Aug 4, 2024
27f2c1e
Merge pull request #62 from SreelekhaB77/patch-1
NisargPipaliya Aug 5, 2024
5ea52b8
added maping for profileDisplay in userController
shubhranshii Aug 10, 2024
58de75c
Update userService.java
shubhranshii Aug 10, 2024
f5aa2a5
Update userDao.java
shubhranshii Aug 10, 2024
70170ca
Merge pull request #73 from shubhranshii/master2
NisargPipaliya Aug 25, 2024
912c388
Merge pull request #32 from BakhshiMoeez/patch-2
NisargPipaliya Aug 25, 2024
c6458e9
[#74] Refactoring DI in controllers
Grad566 Aug 26, 2024
a2a90df
Modified some changes at the AdminController.java
WEBeginner Aug 30, 2024
b34243b
Add text file for testbranching
WEBeginner Aug 30, 2024
b8826e6
Merge pull request #1 from WEBeginner/feature/add-user-authentication
WEBeginner Aug 30, 2024
1c2a737
modifyTextFiles
CTohQH Aug 30, 2024
30f4d51
modifyTextFile
CTohQH Aug 30, 2024
b817ee0
Merge pull request #2 from CTohQH/modifyTextfile
WEBeginner Aug 30, 2024
0c77c2f
Change Files
CTohQH Aug 30, 2024
45be5e8
Merge pull request #3 from CTohQH/modifyTextfile
WEBeginner Aug 30, 2024
a46bdd0
Merge pull request #78 from WEBeginner/master2
NisargPipaliya Sep 9, 2024
32824a0
Merge pull request #75 from Grad566/master2
NisargPipaliya Sep 9, 2024
7614a5a
feat(security): add Spring Security for admin roles and update relate…
Guhapriya01 Sep 12, 2024
e5d500d
feat(security): update UserController and improve security configurat…
Guhapriya01 Sep 12, 2024
0111589
style: customize 403 error page with improved design
Guhapriya01 Sep 12, 2024
57db940
chore: update configuration and dependencies
Guhapriya01 Sep 12, 2024
08b89fb
Merge pull request #80 from Guhapriya01/feature/security-enhancements
NisargPipaliya Sep 13, 2024
d9f3fc8
Update TestBranching
jaygajera17 Sep 18, 2024
a229716
remove: unwanted files
jay-gajera-17 Sep 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .github/workflows/label.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# This workflow will triage pull requests and apply a label based on the
# paths that are modified in the pull request.
#
# To use this workflow, you will need to set up a .github/labeler.yml
# file with configuration. For more information, see:
# https://github.com/actions/labeler

name: Labeler
on: [pull_request_target]

jobs:
label:

runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write

steps:
- uses: actions/[email protected]
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
30 changes: 15 additions & 15 deletions JtProject/.classpath
Original file line number Diff line number Diff line change
@@ -1,24 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
<attributes>
<attribute name="maven.pomderived" value="true"/>
Expand All @@ -31,19 +18,32 @@
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="target/generated-sources/annotations">
<attributes>
<attribute name="ignore_optional_problems" value="true"/>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="ignore_optional_problems" value="true"/>
<attribute name="m2e-apt" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="target/generated-test-sources/test-annotations">
<attributes>
<attribute name="optional" value="true"/>
Expand Down
6 changes: 6 additions & 0 deletions JtProject/.project
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
Expand All @@ -24,6 +29,7 @@
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
</natures>
<filteredResources>
<filter>
Expand Down
2 changes: 1 addition & 1 deletion JtProject/basedata.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# SQL configs
SET SQL_MODE ='IGNORE_SPACE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
SET SQL_MODE ='IGNORE_SPACE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';

# create database and use it
CREATE DATABASE IF NOT EXISTS ecommjava;
Expand Down
8 changes: 6 additions & 2 deletions JtProject/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@
<artifactId>mysql-connector-java</artifactId>
<version>8.0.33</version>
</dependency>


<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>

</dependencies>

Expand All @@ -70,4 +74,4 @@
</plugins>
</build>

</project>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
package com.jtspringproject.JtSpringProject.configuration;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
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;

import com.jtspringproject.JtSpringProject.models.User;
import com.jtspringproject.JtSpringProject.services.userService;

@Configuration
public class SecurityConfiguration {

userService UserService;

public SecurityConfiguration(userService UserService) {
this.UserService = UserService;
}

@Configuration
@Order(1)
public static class AdminConfigurationAdapter{

@Bean
SecurityFilterChain adminFilterChain(HttpSecurity http) throws Exception {
http.antMatcher("/admin/**")
.authorizeHttpRequests(requests -> requests
.requestMatchers(new AntPathRequestMatcher("/admin/login")).permitAll()
.requestMatchers(new AntPathRequestMatcher("/admin/**")).hasRole("ADMIN")
)
.formLogin(login -> login
.loginPage("/admin/login")
.loginProcessingUrl("/admin/loginvalidate")
.successHandler((request, response, authentication) -> {
response.sendRedirect("/admin/"); // Redirect on success
})
.failureHandler((request, response, exception) -> {
response.sendRedirect("/admin/login?error=true"); // Redirect on failure
}))

.logout(logout -> logout.logoutUrl("/admin/logout")
.logoutSuccessUrl("/admin/login")
.deleteCookies("JSESSIONID"))
.exceptionHandling(exception -> exception
.accessDeniedPage("/403") // Custom 403 page
);
http.csrf(csrf -> csrf.disable());
return http.build();
}
}

@Configuration
@Order(2)
public static class UserConfigurationAdapter{

@Bean
SecurityFilterChain userFilterChain(HttpSecurity http) throws Exception {
http.authorizeHttpRequests(requests -> requests
.antMatchers("/login", "/register", "/newuserregister" ,"/test", "/test2").permitAll()
.antMatchers("/**").hasRole("USER"))
.formLogin(login -> login
.loginPage("/login")
.loginProcessingUrl("/userloginvalidate")
.successHandler((request, response, authentication) -> {
response.sendRedirect("/"); // Redirect on success
})
.failureHandler((request, response, exception) -> {
response.sendRedirect("/login?error=true"); // Redirect on failure
}))

.logout(logout -> logout.logoutUrl("/logout")
.logoutSuccessUrl("/login")
.deleteCookies("JSESSIONID"))
.exceptionHandling(exception -> exception
.accessDeniedPage("/403") // Custom 403 page
);

http.csrf(csrf -> csrf.disable());
return http.build();
}
}

@Bean
UserDetailsService userDetailsService() {
return username -> {
User user = UserService.getUserByUsername(username);
if(user == null) {
throw new UsernameNotFoundException("User with username " + username + " not found.");
}
String role = user.getRole().equals("ROLE_ADMIN") ? "ADMIN":"USER";

return org.springframework.security.core.userdetails.User
.withUsername(username)
.passwordEncoder(input->passwordEncoder().encode(input))
.password(user.getPassword())
.roles(role)
.build();
};
}

@Bean
PasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
}
}
Loading