#Spring cloud starter security was removed in spring cloud update 2020.0

138 messages · Page 1 of 1 (latest)

pseudo hamletBOT
#

Hey, @somber mauve!
Please remember to /close this post once your question has been answered!

#
109ms
#

<@&765578700724371486>

Requested by Mailar#2854
somber mauve
#

Spring cloud start security was removed in spring cloud update 2020.0

#

Spring cloud starter security was removed in spring cloud update 2020.0

fierce surge
#

just use the other spring-cloud-xxx dependencies?

somber mauve
#

This are the plugins I have

  id 'checkstyle'
  id 'com.github.sherter.google-java-format' version '0.9'
  id 'com.google.cloud.tools.jib' version '3.1.4'
  id 'idea'
  id 'io.freefair.lombok' version '6.4.2'
  id 'io.spring.dependency-management' version '1.0.15.RELEASE'
  id 'java'
  id 'name.remal.sonarlint' version '1.0.164' // 1.0.165+ causes jakarta.validation/javax.validation conflict
  id 'org.springframework.boot' version '2.5.14'
  id 'org.owasp.dependencycheck' version '6.0.3'
  id 'org.sonarqube' version '2.8'
  id 'jacoco'
}```
#

These are the depencies I have

dependencyManagement {
  imports {
    mavenBom 'org.springframework.cloud:spring-cloud-dependencies:2021.0.4'
  }
}


dependencies {
  implementation 'io.micrometer:micrometer-registry-elastic:1.3.4'
  implementation 'io.micrometer:micrometer-registry-prometheus:1.7.4'
  implementation 'io.zipkin.aws:brave-propagation-aws:0.21.2'
  implementation 'io.zipkin.aws:zipkin-reporter-xray-udp:0.21.2'
  implementation 'net.logstash.logback:logstash-logback-encoder:6.3'
  implementation 'org.springframework.boot:spring-boot-starter-data-redis'
  implementation 'org.springframework.boot:spring-boot-starter-oauth2-client'
  implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
  implementation 'org.springframework.boot:spring-boot-starter-validation'
  implementation 'org.springframework.boot:spring-boot-starter-security'
  implementation 'org.springframework.cloud:spring-cloud-starter-gateway'

  // TODO: Remove starter-security
  implementation 'org.springframework.cloud:spring-cloud-starter-security'

  implementation 'org.springframework.cloud:spring-cloud-starter-sleuth'
  implementation 'org.springframework.security:spring-security-oauth2-jose'
  implementation 'org.springframework.session:spring-session-data-redis'```
fierce surge
#

What do you need spring cloud starter security for?

somber mauve
#

I dont know thats the thing

fierce surge
#

just remove it and see what doesn't work?

somber mauve
#

So

#

/proxy/filter/RefreshAuthTokenGatewayFilterFactory.java:15: error: package org.springframework.cloud.security.oauth2.gateway does not exist
import org.springframework.cloud.security.oauth2.gateway.TokenRelayGatewayFilterFactory;
^
1 error

somber mauve
somber mauve
#

Ok let me check that out tomorrow

somber mauve
#

if you can explain more about the solution you found

drifting badge
somber mauve
#

oh but i have implementation 'org.springframework.cloud:spring-cloud-starter-gateway'

somber mauve
#

**I have removed **

  • org.springframework.cloud:spring-cloud-starter-security
  • org.springframework.cloud:spring-cloud-starter-kubernetes-all

I have updated

  • Java 17,
  • Spring cloud 2021.0.4,
  • Spring boot 2.5.14,
  • Gradle 7.4.x,

Current spring dependencies

  implementation 'org.springframework.boot:spring-boot-starter-data-redis'
  implementation 'org.springframework.boot:spring-boot-starter-oauth2-client'
  implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
  implementation 'org.springframework.boot:spring-boot-starter-validation'
  implementation 'org.springframework.cloud:spring-cloud-starter-gateway'
  implementation 'org.springframework.cloud:spring-cloud-starter-sleuth'
  implementation 'org.springframework.security:spring-security-oauth2-jose'
  implementation 'org.springframework.session:spring-session-data-redis'```

**I run the program ./gradlew bootRun**

```java
/proxy/filter/RefreshAuthTokenGatewayFilterFactory.java:15: error: package org.springframework.cloud.security.oauth2.gateway does not exist.

import org.springframework.cloud.security.oauth2.gateway.TokenRelayGatewayFilterFactory;```

**What I do wrong?**
somber mauve
drifting badge
#

Make sure version recent enough I guess? Though 2021 should be tight

#

Right*

somber mauve
#

I am looking for this TokenRelayGatewayFilterFactory class
It was imported class inside the spring-cloud-starter-security

But now the spring-cloud-starter-security has been deleted from spring-cloud project
What spring project they moved this class to?

#

@drifting badge

#

@fierce surge

drifting badge
#

Spring cloud gateway

somber mauve
#

ok let me try that

#

implementation 'org.springframework.cloud:spring-cloud-starter-gateway'

#

this?

#

?

#

it doesnt work

#

same error

somber mauve
#

I seen this but could you explain how can that help me

#

I understand they moved TokenRelayGatewayFilterFactory to spring-cloud-gateway

#

Is this correct? implementation 'org.springframework.cloud:spring-cloud-starter-gateway'

#

To run your own gateway use the spring-cloud-starter-gateway dependency.

#

why it doesnt work then

#

what dependencies are needed to use spring cloud starter gateway

fierce surge
#

and don't forget to update/reload the project in your IDE

somber mauve
#

what does that mean

#

reload/update

#

do you mean like close vscode and open again

fierce surge
#

telling your IDE that you made changes

#

no idea how to do it in VSC but you can try restarting

somber mauve
#

oh like save changes

#

yeah I do that

fierce surge
#

like you may need to inform the autocomplete that you changed what libraries are used etc

#

so that the stuff needs to be redownloaded etc

somber mauve
#

oh

#

how

fierce surge
#

as I said, idk whether VSC needs it/how to do it with VSC

somber mauve
#

how about intellij

#

I use both

fierce surge
#

In IntelliJ, I think you can open the Gradle tab on the right

#

and then there should be a refresh symbol

#

and maybe try running gradlew build

somber mauve
#

oh isee

#

% ./gradlew build

Task :verifyGoogleJavaFormat

The following files are not formatted properly:

filter/FirstLoginGatewayFilterFactory.java
proxy/filter/RefreshAuthTokenGatewayFilterFactory.java

Task :verifyGoogleJavaFormat FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':verifyGoogleJavaFormat'.

Problems: formatting style violations

fierce surge
#

seems like the project requires to follow some style guidelines which it doesn't

somber mauve
#

hmm

somber mauve
#

ok I fixed the styling

#

but i have still the same problem
import org.springframework.cloud.security.oauth2.gateway.TokenRelayGatewayFilterFactory;
^
1 error

#

I have these dependencies

implementation 'org.springframework.boot:spring-boot-starter-data-redis'
implementation 'org.springframework.boot:spring-boot-starter-oauth2-client'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-validation'

// Changes 31.10.2022
implementation 'org.springframework.cloud:spring-cloud-starter'
implementation 'org.springframework.cloud:spring-cloud-starter-config'
implementation 'org.springframework.cloud:spring-cloud-starter-gateway'
implementation 'org.springframework.cloud:spring-cloud-starter-sleuth'
implementation 'org.springframework.cloud:spring-cloud-starter-task'
// ----- ----- ----- ----- ----- -----

implementation 'org.springframework.security:spring-security-oauth2-jose'

#

@fierce surge , @drifting badge

fierce surge
#

no need to ping, we (or at least I) will see it eventually anyways

#

Does gradlew build run successfully?

#

it is a part of Spring Cloud Gateway

#

make sure that the version of Spring Cloud Gateway is sufficiently recent

somber mauve
#

As you can see it doesn't define the version

#
implementation 'org.springframework.boot:spring-boot-starter-oauth2-client'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.cloud:spring-cloud-starter'
implementation 'org.springframework.cloud:spring-cloud-starter-config'
implementation 'org.springframework.cloud:spring-cloud-starter-gateway'
implementation 'org.springframework.cloud:spring-cloud-starter-sleuth' 
implementation 'org.springframework.security:spring-security-oauth2-jose'
implementation 'org.springframework.session:spring-session-data-redis'```
fierce surge
#

What version of Spring Boot do you use?

somber mauve
#

id 'org.springframework.boot' version '2.7.5'

#

mavenBom 'org.springframework.cloud:spring-cloud-dependencies:2021.0.4'

fierce surge
#

yeah, update those

somber mauve
#

cloud and boot?

fierce surge
#

maybe it wasn't yet moved in that version

somber mauve
#

hmm but i got instructed I have to use 2021.0.4

fierce surge
#

what?

somber mauve
#

spring cloud

fierce surge
#

maybe try updating Spring Boot but not Spring cloud?

somber mauve
#

oh yea but on spring boot I got instructed to use 2.7.x

#

actually the latest version is 2.7.5

#

same thing here 2021.0.4

fierce surge
#

oh I thought there were 2.7.x releases after 2.7.5

fierce surge
#

ahhh why is version 2021.0.4 from 2022..?

somber mauve
#

yeah

#

bro why spring updating is so hard

fierce surge
#

because there are a lot of changes

somber mauve
#

true

#

the previous project spring cloud was hoxtron sr8

#

and id 'org.springframework.boot' version '2.3.12.RELEASE'

fierce surge
somber mauve
#

yeah

fierce surge
#

those were all between

somber mauve
#

oh i see

#

so what is the best way to solve this

fierce surge
#

ok Spring Cloud Gateway 3.1.4 which is included in Spring Cloud 2021.0.4 definetely has TokenRelayGatewayFilterFactory

#

Can you show your whole build.gradle?

somber mauve
#

ok

fierce surge
#

or actually, run gradle -q dependencies

#

that should show you the dependencies in use

somber mauve
#

its alot

#

let me just show the build.gradle

fierce surge
somber mauve
#

oh

#

so do I copy them here?

fierce surge
#

yeah

#

and make sure to use the correct package for TokenRelayGatewayFilterFactory

#

it should be org.springframework.cloud.gateway.filter.factory.TokenRelayGatewayFilterFactory

somber mauve
#

this is like just one part

fierce surge
#

| +--- org.springframework.cloud:spring-cloud-gateway-server:3.1.4

somber mauve
fierce surge
#

you are definetely using the right version

fierce surge
#

Security-->Gateway

#

and the package name was updated as well

somber mauve
#

oh

#

it looks like

#

it doesnt complain anymore about that TokenRelayGatewayFilterFactory

fierce surge
#

lol

somber mauve
#

so it was the freaking path of the import

#

it only complains about checkstyle now