Skip to content
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

Op-21723:CVE-fixes with java-17 and spring-boot upgrade-v4.1 #469

Merged
merged 108 commits into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
108 commits
Select commit Hold shift + click to select a range
18bef6d
OP-21723 : CVE fix for Gate service
vivek-opsmx Apr 17, 2024
7e8f0cf
OP-21723 : Added .Spinnaker/ Url
vivek-opsmx Apr 18, 2024
2621e66
OP-21723 : Removing .Spinnaker/ Url
vivek-opsmx Apr 18, 2024
d251b7e
OP-21723 : Adding Logs
vivek-opsmx Apr 18, 2024
d3f2ae2
OP-21723 : Added few more Logs
vivek-opsmx Apr 18, 2024
6d6f7aa
OP-21723 : changed forceEnable to false
vivek-opsmx Apr 18, 2024
123b3fd
OP-21723 : Added @Configuration annotation
vivek-opsmx Apr 19, 2024
d9c68a2
OP-21723 : Reverted the changes
vivek-opsmx Apr 19, 2024
5aea635
OP-21723 : made ExtendedFiatService to false
vivek-opsmx Apr 19, 2024
bf26233
OP-21723 : Added ConditionalOnExpression
vivek-opsmx Apr 19, 2024
4cf197e
OP-21723 : Added ConditionalOnExpression given false
vivek-opsmx Apr 19, 2024
4279ec3
OP-21723 : Removed ConditionalOnExpression given false
vivek-opsmx Apr 19, 2024
f015b63
OP-21723 :Added Autowired to fiat service
vivek-opsmx Apr 22, 2024
125950a
OP-21723 :Removed Autowired to fiat service
vivek-opsmx Apr 22, 2024
68be879
OP-21723 :Removed @Bean
vivek-opsmx Apr 22, 2024
eec6ea3
OP-21723 : reverted @Bean and made fiatLoginService forceEnabled to …
vivek-opsmx Apr 22, 2024
0b526a6
OP-21723 : commented MethodSecurityExpressionHandler
vivek-opsmx Apr 22, 2024
f1bfe3d
OP-21723 : commented MethodSecurityExpressionHandler
vivek-opsmx Apr 22, 2024
3b004b7
OP-21723 : uncommented MethodSecurityExpressionHandler
vivek-opsmx Apr 22, 2024
a13c2e5
OP-21723 : enabled to true
vivek-opsmx Apr 22, 2024
77ee51e
OP-21723 : reverted gradle properties
vivek-opsmx Apr 22, 2024
869f221
OP-21723 : reverted fiat version to 1.36.0
vivek-opsmx Apr 23, 2024
d1074c2
OP-21723 : reverted fiat version to 1-0-SNAPSHOT
vivek-opsmx Apr 23, 2024
2204d9d
OP-21723 : made fiat version to 1.36.0
vivek-opsmx Apr 23, 2024
1bd770b
OP-21723 : comminted fait code for teting
vivek-opsmx Apr 23, 2024
1287c1e
OP-21723 : reverted all changes
vivek-opsmx Apr 23, 2024
bffbeb0
OP-21723 : comminted expressionHandler
vivek-opsmx Apr 23, 2024
b1dc389
OP-21723 : uncommented expressionHandler code
vivek-opsmx Apr 25, 2024
f328134
OP-21723 : commented fiat code
vivek-opsmx Apr 25, 2024
fe1216a
OP-21723 : added Base URL in feingClient class
vivek-opsmx Apr 25, 2024
9e0d171
OP-21723 : removed Fait code
vivek-opsmx Apr 25, 2024
f59809e
OP-21723 : Removed Unwanted code
vivek-opsmx Apr 25, 2024
5bf153f
OP-21723 : Removed Unwanted codes
vivek-opsmx Apr 25, 2024
a5e3426
OP-21723 : Modified code
vivek-opsmx Apr 26, 2024
84faf71
OP-21723 : disabled fiat service
vivek-opsmx Apr 29, 2024
0db9967
OP-21723 : added Code
vivek-opsmx Apr 29, 2024
f3e081f
OP-21723 : Removed BearerTokenExtractor
vivek-opsmx Apr 29, 2024
eb9b198
OP-21723 : Made @Autowired(required = false)
vivek-opsmx Apr 29, 2024
fb3ad6b
OP-21723 : Added @Lazy in OpsmxPlatformController
vivek-opsmx Apr 29, 2024
d7fdd85
OP-21723 : Removed @Service in OpsmxPlatformService class
vivek-opsmx Apr 29, 2024
9d61663
OP-21723 : made @Autowired(required = false) for all service
vivek-opsmx Apr 29, 2024
9d0aeb3
OP-21723 : made @Autowired(required = false) for auditService
vivek-opsmx Apr 29, 2024
6d284d6
OP-21723 : made @Autowired(required = false) for auditService1
vivek-opsmx Apr 29, 2024
1766ff6
OP-21723 : BearerTokenExtractor code
vivek-opsmx Apr 30, 2024
dac68c9
OP-21723 : code fix
vivek-opsmx Apr 30, 2024
f58c3af
OP-21723 : reverted code
vivek-opsmx Apr 30, 2024
8182f69
OP-21723 : added Logs
vivek-opsmx Apr 30, 2024
6587d33
OP-21723 : added code in ldap class
vivek-opsmx May 2, 2024
b3094bb
OP-21723 : made permissionService to false
vivek-opsmx May 2, 2024
1827359
OP-21723 : Added Some more logs to debug the issue
vivek-opsmx May 3, 2024
941174a
OP-21723 : Added Logs In /login url
vivek-opsmx May 6, 2024
0c71fb6
OP-21723 : Commented @Scheduled in some classes to debug
vivek-opsmx May 6, 2024
194a590
OP-21723 : made fiat to false
vivek-opsmx May 6, 2024
4a0ed47
OP-21723 : made fiat to false in yml
vivek-opsmx May 6, 2024
60dc5e6
OP-21723 : commented fiat code in GateConfig.groovy class
vivek-opsmx May 6, 2024
b2fcdb7
OP-21723 : commented fiat code in AuthConfig and PermissionService.gr…
vivek-opsmx May 6, 2024
c571fe2
OP-21723 : commented fiat code in SamlSsoEventPublishConfig.java classes
vivek-opsmx May 6, 2024
a55cea0
OP-21723 : commented fiat code in fiatPermissionEvaluator.java classes
vivek-opsmx May 6, 2024
035dd31
OP-21723 : commented fiat code in fiatPermissionEvaluator.java classe
vivek-opsmx May 6, 2024
23b0358
OP-21723 : commented fiat code in fiatPermissionEvaluator.java classe
vivek-opsmx May 6, 2024
50e23a0
OP-21723 : commented fiat code in fiatPermissionEvaluator.java classes
vivek-opsmx May 6, 2024
65ea73f
OP-21723 : Removed Fiat code
vivek-opsmx May 6, 2024
c078d7c
OP-21723 : Removed Fiat code
vivek-opsmx May 6, 2024
e655c9d
OP-21723 : Commented FiatClientConfigurationProperties
vivek-opsmx May 6, 2024
68da77f
OP-21723 : Commented if-condition in AllowedAccountsSupport.java
vivek-opsmx May 6, 2024
d6831db
OP-21723 : Added HTTP request
vivek-opsmx May 6, 2024
3547c9e
OP-21723 : OpsmxAuthController.groovy
vivek-opsmx May 6, 2024
9a1c9fb
OP-21723 : reverted OpsmxAuthController.groovy
vivek-opsmx May 6, 2024
5559cea
OP-21723 : reverted OpsmxAuthController.groovy
vivek-opsmx May 6, 2024
2752641
OP-21723 : Added Logs
vivek-opsmx May 7, 2024
04adbd0
OP-21723 : Upgraded okhttp to 4.x version
vivek-opsmx May 7, 2024
6df1178
OP-21723 : returing user
vivek-opsmx May 8, 2024
be283c1
OP-21723 : OpsmxDashboardController
vivek-opsmx May 8, 2024
7e59202
OP-21723 : Added @service in interface class
vivek-opsmx May 8, 2024
627586f
OP-21723 : Added @ComponentScan in controller class
vivek-opsmx May 8, 2024
988bc46
OP-21723 : opsmxDashboardService @Autowired(required = true)
vivek-opsmx May 8, 2024
44000b7
OP-21723 : opsmxDashboardService @Autowired(required = false)
vivek-opsmx May 8, 2024
8a5de72
OP-21723 : opsmxDashboardService @Autowired(required = false)
vivek-opsmx May 8, 2024
d5db884
OP-21723 : opsmxDashboardService removed @Autowired(required = tr)
vivek-opsmx May 8, 2024
2cf564e
OP-21936: autowired OpsmxDashboardService.
rahul-chekuri May 8, 2024
14141bc
OP-21936: corrected spel expression.
rahul-chekuri May 8, 2024
1688ff4
OP-21723 : Removed (required = false) in all the service
vivek-opsmx May 8, 2024
ce8f296
OP-21723 : Removed Commented code
vivek-opsmx May 8, 2024
3cc38ec
OP-21723 : Removed Commented Code
vivek-opsmx May 9, 2024
5ab94b1
OP-21723 : Added Logs for Debugging
vivek-opsmx May 9, 2024
78780ce
OP-21723 : Added SAML2 codes
vivek-opsmx May 9, 2024
c2f0717
OP-21723 : Added SAML2 code
vivek-opsmx May 9, 2024
7365cf7
OP-21723 : Addressed PR review comments
vivek-opsmx May 10, 2024
3ca6e13
OP-21723 : resolved compile time error and addressed pr review comments
vivek-opsmx May 10, 2024
7b1dbf3
OP-21723 : removed fiat enable - true
vivek-opsmx May 10, 2024
108961c
OP-21723 : removed repositories mavenLocal() mavenCentral()
vivek-opsmx May 10, 2024
f708943
OP-21723 : reverted repositories mavenLocal() mavenCentral()
vivek-opsmx May 10, 2024
d983f81
OP-21723 : Made Change in SamlSecurityConfiguration
vivek-opsmx May 10, 2024
ca67635
OP-21723 : commented loginWithRoles
vivek-opsmx May 10, 2024
f91c187
OP-21723 : commented ss0Config class
vivek-opsmx May 13, 2024
2cf0495
OP-21723 : Reverting ssoConfig class changes
vivek-opsmx May 13, 2024
009ec53
OP-21723 : Reverting gate config
vivek-opsmx May 13, 2024
56abcf4
OP-21723 : Reverting all PR review comments
vivek-opsmx May 13, 2024
1d60cd1
OP-21723 : Reverting all PR review comments 2
vivek-opsmx May 13, 2024
7581eb7
OP-21936: downported changes fron v4.0
rahul-chekuri May 15, 2024
48c3a15
OP-21936: downported changes fron v4.0
rahul-chekuri May 15, 2024
963b929
OP-21936: changed bean name to avoid picking up the wrong beans.
rahul-chekuri May 16, 2024
cfae94d
OP-21936: Annotated with qualifiers to pick beans by names.
rahul-chekuri May 16, 2024
0075703
OP-21936: setting samlAuthenticationManager.
rahul-chekuri May 16, 2024
d70bbdb
OP-21723 : Addressed all PR review comments
vivek-opsmx May 17, 2024
4f2eb9d
OP-21936: cleaned up permission service of fait and put oes one.
rahul-chekuri May 17, 2024
4be6c3c
OP-21936: compilation fix.
rahul-chekuri May 17, 2024
1ca653f
OP-21723 : Addressed PR review comments
vivek-opsmx May 17, 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
2 changes: 1 addition & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
uses: docker/setup-buildx-action@v2
- uses: actions/setup-java@v2
with:
java-version: 11
java-version: 17
distribution: 'zulu'
cache: 'gradle'
- name: Prepare build variables
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
uses: docker/setup-buildx-action@v2
- uses: actions/setup-java@v2
with:
java-version: 11
java-version: 17
distribution: 'zulu'
cache: 'gradle'
- name: Assemble release info
Expand Down
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
FROM registry.access.redhat.com/ubi8/ubi:8.3
MAINTAINER [email protected]
COPY ./gate-web/build/install/gate /opt/gate
RUN yum -y install java-11-openjdk-headless.x86_64 wget vim curl net-tools nettle
RUN yum -y install java-17-openjdk-headless.x86_64 wget vim curl net-tools nettle
RUN yum -y update
RUN adduser spinnaker
RUN mkdir -p /opt/gate/plugins && mkdir -p /opt/spinnaker/plugins
####adding customplugin zip
RUN mkdir -p /opt/gate/plugins && mkdir -p /opt/spinnaker/plugins
####adding customplugin zip
ARG CUSTOMPLUGIN_RELEASEVERSION
ENV CUSTOMPLUGIN_RELEASEVERSION=$CUSTOMPLUGIN_RELEASEVERSION
COPY custom-plugin.json /opt/spinnaker/plugins/plugins.json
Expand All @@ -16,7 +16,7 @@ RUN wget -O VerificationPlugin-v1.0.1-SNAPSHOT.zip -c https://github.com/OpsMx/C
RUN mv VerificationPlugin-v1.0.1-SNAPSHOT.zip /opt/spinnaker/plugins/ \
&& mv TestVerificationPlugin-v1.0.1-SNAPSHOT.zip /opt/spinnaker/plugins/ \
&& mv policyPlugin-v1.0.1-SNAPSHOT.zip /opt/spinnaker/plugins/ \
&& mv ApprovalStagePlugin-v1.0.1-SNAPSHOT.zip /opt/spinnaker/plugins/
&& mv ApprovalStagePlugin-v1.0.1-SNAPSHOT.zip /opt/spinnaker/plugins/

RUN sed -i 's/"VERIFICATION_SHASUM"/'\""$(sha512sum /opt/spinnaker/plugins/VerificationPlugin-v1.0.1-SNAPSHOT.zip | awk '{print $1}')"\"'/g' /opt/spinnaker/plugins/plugins.json \
&& sed -i 's/"TESTVERIFICATION_SHASUM"/'\""$(sha512sum /opt/spinnaker/plugins/TestVerificationPlugin-v1.0.1-SNAPSHOT.zip | awk '{print $1}')"\"'/g' /opt/spinnaker/plugins/plugins.json \
Expand Down
66 changes: 43 additions & 23 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,33 @@ plugins {

allprojects {
apply plugin: 'io.spinnaker.project'
repositories {
mavenLocal()
mavenCentral()
}
tasks.withType( Copy).all {
duplicatesStrategy 'exclude'
}

group = "io.spinnaker.gate"

if (name != "gate-bom") {
apply plugin: 'java-library'
apply plugin: 'groovy'

if ([korkVersion, fiatVersion].find { it.endsWith('-SNAPSHOT') }) {

if ([korkVersion].find { it.endsWith('-SNAPSHOT') }) {
repositories {
mavenLocal()
maven{
url "https://nexus.opsmx.net/repository/maven-snapshots/"
credentials {
username = "NEXUS_USERNAME"
password = "NEXUS_PASSWORD"
}
}
}
}
if (name != "gate-bom" && name != "gate-api") {
apply plugin: 'java-library'
apply plugin: 'groovy'

repositories {
maven { url 'https://build.shibboleth.net/nexus/content/repositories/releases/' }
Expand All @@ -33,43 +48,48 @@ allprojects {
compileOnly "org.projectlombok:lombok"
annotationProcessor "org.projectlombok:lombok"
testAnnotationProcessor "org.projectlombok:lombok"
compile("org.springframework.cloud:spring-cloud-starter-vault-config")
compile("io.micrometer:micrometer-registry-prometheus")


implementation "org.codehaus.groovy:groovy-all"
implementation "net.logstash.logback:logstash-logback-encoder"
implementation "org.apache.groovy:groovy:4.0.9"
implementation "net.logstash.logback:logstash-logback-encoder:4.11"
implementation "org.jetbrains.kotlin:kotlin-reflect"
implementation "org.springframework.security.oauth.boot:spring-security-oauth2-autoconfigure:2.6.0"

testImplementation "org.spockframework:spock-core"
testImplementation "org.spockframework:spock-spring"
testImplementation "org.springframework.boot:spring-boot-starter-test"
testImplementation "org.hamcrest:hamcrest-core"
testRuntimeOnly "cglib:cglib-nodep"
testRuntimeOnly "cglib:cglib-nodep:3.3.0"
testRuntimeOnly "org.objenesis:objenesis"
}

java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

configurations.all {
exclude group: 'javax.servlet', module: 'servlet-api'
exclude group: 'javax.servlet', module: 'javax.servlet-api'
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
if (details.requested.group == 'org.apache.logging.log4j') {
details.useVersion '2.19.0'
}
}
}

tasks.withType(JavaExec) {
if (System.getProperty('DEBUG', 'false') == 'true') {
jvmArgs '-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8184'
}
}

tasks.withType(JavaExec) {
if (System.getProperty('DEBUG', 'false') == 'true') {
jvmArgs '-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8184'
}
}

test {
testLogging {
exceptionFormat = 'full'
test {
testLogging {
exceptionFormat = 'full'
afterSuite { desc, result ->
if (!desc.parent) {
println "Results: ${result.resultType} (${result.testCount} tests, ${result.successfulTestCount} successes, ${result.failedTestCount} failures, ${result.skippedTestCount} skipped)"
println "Report file: ${reports.html.entryPoint}"
}
}
}
useJUnitPlatform()
}
}

Expand Down
8 changes: 4 additions & 4 deletions docker/ubi8/Gate-Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
FROM registry.access.redhat.com/ubi8/ubi:8.3
MAINTAINER [email protected]
COPY ./gate-web/build/install/gate /opt/gate
RUN yum -y install java-11-openjdk-headless.x86_64 wget vim curl net-tools nettle
RUN yum -y install java-17-openjdk-headless.x86_64 wget vim curl net-tools nettle
RUN yum -y update
RUN adduser spinnaker
RUN mkdir -p /opt/gate/plugins && mkdir -p /opt/spinnaker/plugins
####adding customplugin zip
RUN mkdir -p /opt/gate/plugins && mkdir -p /opt/spinnaker/plugins
####adding customplugin zip
ARG CUSTOMPLUGIN_RELEASEVERSION
ENV CUSTOMPLUGIN_RELEASEVERSION=$CUSTOMPLUGIN_RELEASEVERSION
COPY custom-plugin.json /opt/spinnaker/plugins/plugins.json
Expand All @@ -16,7 +16,7 @@ RUN wget -O VerificationPlugin-v1.0.1-SNAPSHOT.zip -c https://github.com/OpsMx/C
RUN mv VerificationPlugin-v1.0.1-SNAPSHOT.zip /opt/spinnaker/plugins/ \
&& mv TestVerificationPlugin-v1.0.1-SNAPSHOT.zip /opt/spinnaker/plugins/ \
&& mv policyPlugin-v1.0.1-SNAPSHOT.zip /opt/spinnaker/plugins/ \
&& mv ApprovalStagePlugin-v1.0.1-SNAPSHOT.zip /opt/spinnaker/plugins/
&& mv ApprovalStagePlugin-v1.0.1-SNAPSHOT.zip /opt/spinnaker/plugins/

RUN sed -i 's/"VERIFICATION_SHASUM"/'\""$(sha512sum /opt/spinnaker/plugins/VerificationPlugin-v1.0.1-SNAPSHOT.zip | awk '{print $1}')"\"'/g' /opt/spinnaker/plugins/plugins.json \
&& sed -i 's/"TESTVERIFICATION_SHASUM"/'\""$(sha512sum /opt/spinnaker/plugins/TestVerificationPlugin-v1.0.1-SNAPSHOT.zip | awk '{print $1}')"\"'/g' /opt/spinnaker/plugins/plugins.json \
Expand Down
2 changes: 1 addition & 1 deletion docker_build/Dockerfile.prod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM quay.io/opsmxpublic/ubi8-jre-11:v1
FROM quay.io/opsmxpublic/ubi8-jre-17:v1
MAINTAINER OpsMx

# Install procps(ps)
Expand Down
9 changes: 5 additions & 4 deletions docker_build/Dockerfile.rhel8-ubi8
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM registry.access.redhat.com/ubi8/ubi:latest
FROM quay.io/opsmxpublic/ubifips:8.7
#FROM registry.access.redhat.com/ubi8/ubi-minimal:8.7 as java-base
MAINTAINER OpsMx

# Disable old version and uninstalling
Expand All @@ -17,16 +18,16 @@ RUN adduser opsmx \

# Install procps(ps)
RUN yum install -y procps nginx net-tools wget
# Install java 11
RUN yum -y install java-11-openjdk-headless.x86_64
# Install java 17
RUN yum -y install tzdata-java java-17-openjdk-headless.x86_64
# Install ping
RUN yum install -y iputils

RUN yum -y update

#######Gate Dependencies#########
ENV WORK_DIR=/opsmx/workdir
ENV JAVA_HOME=/usr/lib/jvm/jre-11-openjdk
ENV JAVA_HOME=/usr/lib/jvm/jre-17-openjdk
COPY /docker_build/run.sh /usr/local/bin/run.sh
RUN chmod +x /usr/local/bin/run.sh
COPY /docker_build/gate.yml /opt/spinnaker/config/
Expand Down
3 changes: 2 additions & 1 deletion gate-api-tck/gate-api-tck.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ dependencies {
implementation(project(":gate-web"))

api("org.springframework.boot:spring-boot-starter-test")
api("dev.minutest:minutest")
api("dev.minutest:minutest:1.13.0")
api("io.mockk:mockk:1.10.5")
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,23 @@

import com.netflix.spinnaker.gate.config.AuthConfig;
import com.netflix.spinnaker.gate.security.SpinnakerAuthConfig;
import com.netflix.spinnaker.gate.services.OesAuthorizationService;
import com.netflix.spinnaker.gate.services.PermissionService;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.AuthenticationServiceException;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.builders.WebSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer;
import org.springframework.security.crypto.factory.PasswordEncoderFactories;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.web.SecurityFilterChain;
import org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint;
import org.springframework.session.web.http.DefaultCookieSerializer;

Expand All @@ -41,11 +43,10 @@
@SpinnakerAuthConfig
@EnableWebSecurity
@Slf4j
public class BasicAuthConfig extends WebSecurityConfigurerAdapter {
public class BasicAuthConfig {

private final AuthConfig authConfig;

private final BasicAuthProvider authProvider;
@Autowired private final AuthConfig authConfig;
@Autowired private final BasicAuthProvider authProvider;

@Autowired DefaultCookieSerializer defaultCookieSerializer;

Expand All @@ -58,19 +59,16 @@ public class BasicAuthConfig extends WebSecurityConfigurerAdapter {
@Value("${security.user.password:}")
String password;

@Autowired PermissionService permissionService;

@Autowired
public BasicAuthConfig(
AuthConfig authConfig,
PermissionService permissionService,
OesAuthorizationService oesAuthorizationService) {
public BasicAuthConfig(AuthConfig authConfig, BasicAuthProvider authProvider) {
this.authConfig = authConfig;
this.authProvider = new BasicAuthProvider(permissionService, oesAuthorizationService);
this.authProvider = authProvider;
}

@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
@Bean
public AuthenticationManager authManager(HttpSecurity http) throws Exception {
AuthenticationManagerBuilder authenticationManagerBuilder =
http.getSharedObject(AuthenticationManagerBuilder.class);
if (name == null || name.isEmpty() || password == null || password.isEmpty()) {
throw new AuthenticationServiceException(
"User credentials are not configured properly. Please check username and password are properly configured");
Expand All @@ -86,22 +84,36 @@ public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception

authProvider.setName(this.name);
authProvider.setPassword(this.password);

auth.authenticationProvider(authProvider);
authenticationManagerBuilder.authenticationProvider(authProvider);
authenticationManagerBuilder.eraseCredentials(false);
return authenticationManagerBuilder.build();
}

@Override
protected void configure(HttpSecurity http) throws Exception {
@Bean
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
defaultCookieSerializer.setSameSite(null);
http.csrf().disable();
http.formLogin()
.and()
.httpBasic()
.authenticationEntryPoint(new LoginUrlAuthenticationEntryPoint("/login"));
authConfig.configure(http);
return http.build();
}

@Bean
public WebSecurityCustomizer webSecurityCustomizer() {
return (web) -> {
try {
authConfig.configure(web);
} catch (Exception e) {
throw new RuntimeException(e);
}
};
}

@Override
public void configure(WebSecurity web) throws Exception {
authConfig.configure(web);
@Bean
public PasswordEncoder passwordEncoder() {
return PasswordEncoderFactories.createDelegatingPasswordEncoder();
}
}
Loading
Loading