diff --git a/.gitignore b/.gitignore index 4c91246..66794a2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,98 @@ -/.gradle/ -/target/ -/build/ -/bin/ +# Maven +target/ +pom.xml.tag +pom.xml.releaseBackup +pom.xml.versionsBackup +pom.xml.next +release.properties +dependency-reduced-pom.xml +buildNumber.properties +.mvn/timing.properties +.mvn/wrapper/maven-wrapper.jar + +# Gradle +**/build/ +.gradle +gradle-app.setting +!gradle-wrapper.jar +!gradle-wrapper.properties +.gradletasknamecache + +# Java +*.class +*.log +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar +hs_err_pid* +replay_pid* + +# Eclipse +# CRITICAL: For multi-module projects, DO NOT ignore .project, .classpath, or .settings/ +# These files MUST be committed for clean customer import experience +.metadata +bin/ +tmp/ +*.tmp +*.bak +*.swp +*~.nib +local.properties +.loadpath +.recommenders +.externalToolBuilders/ +*.launch +.buildpath +.target +.tern-project +.texlipse +.springBeans +.recommenders/ +.apt_generated/ +.apt_generated_test/ +.factorypath +.c9/ +*.pydevproject +.cproject +.autotools +.externalToolBuilders/ +.launches/ + +# IntelliJ IDEA +.idea/ +*.iws +*.iml +*.ipr +out/ +.idea_modules/ + +# VS Code +.vscode/ +*.code-workspace +.history/ + +# macOS +.DS_Store +.AppleDouble +.LSOverride +Icon +._* + +# Windows +Thumbs.db +ehthumbs.db +*.stackdump +[Dd]esktop.ini +$RECYCLE.BIN/ +*.lnk + +# Linux +*~ +.fuse_hidden* +.directory +.Trash-* +.nfs* diff --git a/.settings/org.eclipse.wst.common.project.facet.core.xml b/.settings/org.eclipse.wst.common.project.facet.core.xml index cea524a..1bfcd9b 100644 --- a/.settings/org.eclipse.wst.common.project.facet.core.xml +++ b/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -2,6 +2,6 @@ - - + + diff --git a/cics-java-liberty-springboot-security-app/.classpath b/cics-java-liberty-springboot-security-app/.classpath new file mode 100644 index 0000000..97233ed --- /dev/null +++ b/cics-java-liberty-springboot-security-app/.classpath @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/cics-java-liberty-springboot-security-app/.project b/cics-java-liberty-springboot-security-app/.project new file mode 100644 index 0000000..c85f7b5 --- /dev/null +++ b/cics-java-liberty-springboot-security-app/.project @@ -0,0 +1,37 @@ + + + com.ibm.cicsdev.springboot.security + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.buildship.core.gradleprojectbuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + org.eclipse.wst.common.project.facet.core.nature + org.eclipse.buildship.core.gradleprojectnature + + diff --git a/cics-java-liberty-springboot-security-app/.settings/org.eclipse.buildship.core.prefs b/cics-java-liberty-springboot-security-app/.settings/org.eclipse.buildship.core.prefs new file mode 100644 index 0000000..e889521 --- /dev/null +++ b/cics-java-liberty-springboot-security-app/.settings/org.eclipse.buildship.core.prefs @@ -0,0 +1,2 @@ +connection.project.dir= +eclipse.preferences.version=1 diff --git a/cics-java-liberty-springboot-security-app/.settings/org.eclipse.wst.common.component b/cics-java-liberty-springboot-security-app/.settings/org.eclipse.wst.common.component new file mode 100644 index 0000000..f68927d --- /dev/null +++ b/cics-java-liberty-springboot-security-app/.settings/org.eclipse.wst.common.component @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/cics-java-liberty-springboot-security-app/.settings/org.eclipse.wst.common.project.facet.core.xml b/cics-java-liberty-springboot-security-app/.settings/org.eclipse.wst.common.project.facet.core.xml new file mode 100644 index 0000000..1bfcd9b --- /dev/null +++ b/cics-java-liberty-springboot-security-app/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/build.gradle b/cics-java-liberty-springboot-security-app/build.gradle similarity index 100% rename from build.gradle rename to cics-java-liberty-springboot-security-app/build.gradle diff --git a/cics-java-liberty-springboot-security-app/pom.xml b/cics-java-liberty-springboot-security-app/pom.xml new file mode 100644 index 0000000..ed039ff --- /dev/null +++ b/cics-java-liberty-springboot-security-app/pom.xml @@ -0,0 +1,90 @@ + + 4.0.0 + + + + com.ibm.cicsdev.springboot + cics-java-liberty-springboot-security + 0.1.0 + ../pom.xml + + + + cics-java-liberty-springboot-security-app + com.ibm.cicsdev.springboot.security.app + Spring Boot Web Secure Sample with Jakarta EE pre-authentication - Application + war + + 17 + UTF-8 + ${java.version} + true + + + + + + + + com.ibm.cics + com.ibm.cics.ts.bom + 6.1-20250812133513-PH63856 + pom + import + + + + + + + + com.ibm.cics + com.ibm.cics.server + + + + + org.springframework.boot + spring-boot-starter-web + + + + + org.springframework.boot + spring-boot-starter-tomcat + provided + + + + + org.springframework.boot + spring-boot-starter-security + + + + + org.springframework.boot + spring-boot-starter-thymeleaf + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + org.apache.maven.plugins + maven-compiler-plugin + + ${java.version} + + + + + + diff --git a/src/main/java/com/ibm/cicsdev/springboot/security/Application.java b/cics-java-liberty-springboot-security-app/src/main/java/com/ibm/cicsdev/springboot/security/Application.java similarity index 84% rename from src/main/java/com/ibm/cicsdev/springboot/security/Application.java rename to cics-java-liberty-springboot-security-app/src/main/java/com/ibm/cicsdev/springboot/security/Application.java index 6d21c8a..77e2beb 100644 --- a/src/main/java/com/ibm/cicsdev/springboot/security/Application.java +++ b/cics-java-liberty-springboot-security-app/src/main/java/com/ibm/cicsdev/springboot/security/Application.java @@ -18,6 +18,7 @@ import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.web.SecurityFilterChain; +import org.springframework.security.web.util.matcher.AntPathRequestMatcher; import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; @@ -53,10 +54,15 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception http .authorizeHttpRequests(authz -> authz // Allow access to URLs required for form login - .requestMatchers("/login", "/resources/**", "/j_security_check","css/**").permitAll() + .requestMatchers("/login", "/resources/**", "/j_security_check", "/css/**").permitAll() .anyRequest().authenticated() ) - // Use Jakarta EE pre-authentication and map these roles to Spring Security + // Disable CSRF for j_security_check — this endpoint is handled by Liberty's + // Java EE form authentication, not by Spring Security, so no CSRF token is + // available in the form POST. All other endpoints retain CSRF protection. + .csrf(csrf -> csrf + .ignoringRequestMatchers(new AntPathRequestMatcher("/j_security_check")) + ) .jee(jee -> jee.mappableRoles("USER", "ADMIN")); return http.build(); diff --git a/src/main/java/com/ibm/cicsdev/springboot/security/ServletInitializer.java b/cics-java-liberty-springboot-security-app/src/main/java/com/ibm/cicsdev/springboot/security/ServletInitializer.java similarity index 100% rename from src/main/java/com/ibm/cicsdev/springboot/security/ServletInitializer.java rename to cics-java-liberty-springboot-security-app/src/main/java/com/ibm/cicsdev/springboot/security/ServletInitializer.java diff --git a/src/main/java/com/ibm/cicsdev/springboot/security/WebSecureController.java b/cics-java-liberty-springboot-security-app/src/main/java/com/ibm/cicsdev/springboot/security/WebSecureController.java similarity index 100% rename from src/main/java/com/ibm/cicsdev/springboot/security/WebSecureController.java rename to cics-java-liberty-springboot-security-app/src/main/java/com/ibm/cicsdev/springboot/security/WebSecureController.java diff --git a/cics-java-liberty-springboot-security-app/src/main/resources/application.properties b/cics-java-liberty-springboot-security-app/src/main/resources/application.properties new file mode 100644 index 0000000..6aa7d61 --- /dev/null +++ b/cics-java-liberty-springboot-security-app/src/main/resources/application.properties @@ -0,0 +1,13 @@ +spring.thymeleaf.cache=false + +# Spring Security user (used for local/standalone testing only — +# overridden by Liberty SAF/RACF authentication when deployed to CICS) +spring.security.user.name=user +spring.security.user.password=password + +# Logging — set to DEBUG for detailed Spring Security filter chain diagnostics +# (useful when troubleshooting authentication/authorisation issues on Liberty) +# Switch back to INFO for normal operation +logging.level.org.springframework.security=DEBUG +logging.level.org.springframework.web=INFO +logging.level.org.springframework.boot.actuate.audit.listener.AuditListener=DEBUG diff --git a/src/main/resources/static/css/bootstrap.min.css b/cics-java-liberty-springboot-security-app/src/main/resources/static/css/bootstrap.min.css similarity index 100% rename from src/main/resources/static/css/bootstrap.min.css rename to cics-java-liberty-springboot-security-app/src/main/resources/static/css/bootstrap.min.css diff --git a/src/main/resources/templates/error.html b/cics-java-liberty-springboot-security-app/src/main/resources/templates/error.html similarity index 100% rename from src/main/resources/templates/error.html rename to cics-java-liberty-springboot-security-app/src/main/resources/templates/error.html diff --git a/src/main/resources/templates/home.html b/cics-java-liberty-springboot-security-app/src/main/resources/templates/home.html similarity index 100% rename from src/main/resources/templates/home.html rename to cics-java-liberty-springboot-security-app/src/main/resources/templates/home.html diff --git a/src/main/resources/templates/login.html b/cics-java-liberty-springboot-security-app/src/main/resources/templates/login.html similarity index 100% rename from src/main/resources/templates/login.html rename to cics-java-liberty-springboot-security-app/src/main/resources/templates/login.html diff --git a/src/main/webapp/WEB-INF/web.xml b/cics-java-liberty-springboot-security-app/src/main/webapp/WEB-INF/web.xml similarity index 100% rename from src/main/webapp/WEB-INF/web.xml rename to cics-java-liberty-springboot-security-app/src/main/webapp/WEB-INF/web.xml diff --git a/cics-java-liberty-springboot-security-cicsbundle/build.gradle b/cics-java-liberty-springboot-security-cicsbundle/build.gradle new file mode 100644 index 0000000..f0116e8 --- /dev/null +++ b/cics-java-liberty-springboot-security-cicsbundle/build.gradle @@ -0,0 +1,34 @@ +// ============================================================================ +// Plugins +// ============================================================================ +plugins +{ + id 'com.ibm.cics.bundle' version '1.0.8' +} + +// ============================================================================ +// Project Information +// ============================================================================ +description = 'CICS Spring Boot Security Application - CICS Bundle' +version = '0.1.0' + +// ============================================================================ +// Dependencies +// ============================================================================ +dependencies +{ + // Application WAR from sibling project + cicsBundlePart project(path: ':cics-java-liberty-springboot-security-app', configuration: 'archives') +} + +// ============================================================================ +// CICS Bundle Configuration +// ============================================================================ +cicsBundle +{ + build + { + defaultJVMServer = project.findProperty('cics.jvmserver') ?: 'DFHWLP' + } +} + diff --git a/cics-java-liberty-springboot-security-cicsbundle/pom.xml b/cics-java-liberty-springboot-security-cicsbundle/pom.xml new file mode 100644 index 0000000..2bd3d0a --- /dev/null +++ b/cics-java-liberty-springboot-security-cicsbundle/pom.xml @@ -0,0 +1,55 @@ + + + 4.0.0 + + + + + + com.ibm.cicsdev.springboot + cics-java-liberty-springboot-security + 0.1.0 + ../pom.xml + + + + + + cics-java-liberty-springboot-security-cicsbundle + cics-bundle + CICS Spring Boot Security - CICS Bundle + + + + + + + + ${project.groupId} + cics-java-liberty-springboot-security-app + ${project.version} + war + + + + + + + + + + + com.ibm.cics + cics-bundle-maven-plugin + 1.0.8 + true + + ${cics.jvmserver} + + + + + + diff --git a/pom.xml b/pom.xml index 29b842c..3317603 100644 --- a/pom.xml +++ b/pom.xml @@ -1,6 +1,5 @@ - + 4.0.0 @@ -12,23 +11,26 @@ - + + + com.ibm.cicsdev.springboot cics-java-liberty-springboot-security 0.1.0 - cics-java-liberty-springboot-security - Spring Boot Web Secure Sample with Jakarta EE pre-authentication + Demo project for Spring Boot with CICS Security + pom + 17 UTF-8 - ${java.version} - ${java.version} + ${java.version} + DFHWLP - + - + com.ibm.cics com.ibm.cics.ts.bom @@ -38,56 +40,14 @@ - - - - - com.ibm.cics - com.ibm.cics.server - - - - - org.springframework.boot - spring-boot-starter-web - - - - - org.springframework.boot - spring-boot-starter-tomcat - provided - - - - - org.springframework.boot - spring-boot-starter-security - - - - - org.springframework.boot - spring-boot-starter-thymeleaf - - - - - war - - - - org.springframework.boot - spring-boot-maven-plugin - - - org.apache.maven.plugins - maven-compiler-plugin - - ${java.version} - - - - + + + + + + cics-java-liberty-springboot-security-app + cics-java-liberty-springboot-security-cicsbundle + + diff --git a/settings.gradle b/settings.gradle index 5dba858..4b1e2e4 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,8 +1,16 @@ // ============================================================================ // Root Project Configuration +// ============================================================================ plugins { id 'org.gradle.toolchains.foojay-resolver-convention' version '0.9.0' } +rootProject.name = 'cics-java-liberty-springboot-security' + +// ============================================================================ +// Subprojects // ============================================================================ -rootProject.name = 'com.ibm.cicsdev.springboot.security' +include(':cics-java-liberty-springboot-security-app') +include(':cics-java-liberty-springboot-security-cicsbundle') + + diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties deleted file mode 100644 index 8e13244..0000000 --- a/src/main/resources/application.properties +++ /dev/null @@ -1,7 +0,0 @@ -spring.thymeleaf.cache=false -# demo only: -logging.level.org.springframework.security=INFO -logging.level.org.springframework.web=INFO -logging.level.org.springframework.boot.actuate.audit.listener.AuditListene=DEBUG -spring.security.user.name=user -spring.security.user.password=password