Keycloak Ouath2 integration is not working in spring cloud dataflow 2.3.0 - spring-boot

I am currently trying to integrate keycloak with spring cloud dataflow 2.3.0 but the configurations are showing in the documentation is not working for this version. I tried the same with version spring cloud dataflow 2.2.2 and the integrations worked okay. This the config I am added in application.yaml for both the versions,
spring:
cloud:
dataflow:
security:
authorization:
map-oauth-scopes: true
security:
oauth2:
client:
client-id: dataflow
client-secret: 44ed8e53-f52f-4d2e-a205
access-token-uri: http://localhost:8080/auth/realms/dataflow/protocol/openid-connect/token
user-authorization-uri: http://localhost:8080/auth/realms/dataflow/protocol/openid-connect/auth
resource:
user-info-uri: http://localhost:8080/auth/realms/dataflow/protocol/openid-connect/userinfo
token-info-uri: http://localhost:8080/auth/realms/dataflow/protocol/openid-connect/token/introspect
I can see the below entries in the 2.2.2 logs after the config is applied but not in 2.3.0
2020-10-18 11:31:40.829 INFO 1 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.PostgreSQL95Dialect
2020-10-18 11:31:40.977 INFO 1 --- [ main] org.hibernate.type.BasicTypeRegistry : HHH000270: Type registration [java.util.UUID] overrides previous : org.hibernate.type.UUIDBinaryType#5965844d
2020-10-18 11:31:42.027 INFO 1 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2020-10-18 11:31:43.113 INFO 1 --- [ main] o.s.c.c.s.support.SecurityConfigUtils : Authorization 'GET' | 'hasRole('ROLE_VIEW')' | '/about'
2020-10-18 11:31:43.114 INFO 1 --- [ main] o.s.c.c.s.support.SecurityConfigUtils : Authorization 'GET' | 'hasRole('ROLE_VIEW')' | '/audit-records'
2020-10-18 11:31:43.121 INFO 1 --- [ main] o.s.c.c.s.support.SecurityConfigUtils : Authorization 'GET' | 'hasRole('ROLE_VIEW')' | '/audit-records/**'
2020-10-18 11:31:43.122 INFO 1 --- [ main] o.s.c.c.s.support.SecurityConfigUtils : Authorization 'GET' | 'hasRole('ROLE_MANAGE')' | '/management/**'
2020-10-18 11:31:43.122 INFO 1 --- [ main] o.s.c.c.s.support.SecurityConfigUtils : Authorization 'GET' | 'hasRole('ROLE_VIEW')' | '/apps'
2020-10-18 11:31:43.122 INFO 1 --- [ main] o.s.c.c.s.support.SecurityConfigUtils : Authorization 'GET' | 'hasRole('ROLE_VIEW')' | '/apps/**'
2020-10-18 11:31:43.123 INFO 1 --- [ main] o.s.c.c.s.support.SecurityConfigUtils : Authorization 'DELETE' | 'hasRole('ROLE_DESTROY')' | '/apps/**'
2020-10-18 11:31:43.123 INFO 1 --- [ main] o.s.c.c.s.support.SecurityConfigUtils : Authorization 'POST' | 'hasRole('ROLE_CREATE')' | '/apps'
2020-10-18 11:31:43.123 INFO 1 --- [ main] o.s.c.c.s.support.SecurityConfigUtils : Authorization 'POST' | 'hasRole('ROLE_CREATE')' | '/apps/**'
2020-10-18 11:31:43.124 INFO 1 --- [ main] o.s.c.c.s.support.SecurityConfigUtils : Authorization 'PUT' | 'hasRole('ROLE_MODIFY')' | '/apps/**'
I have followed the details in here https://docs.spring.io/spring-cloud-dataflow/docs/2.3.0.RELEASE/reference/htmlsingle/#configuration-security-oauth2 and don't understand why it's not working in 2.3.0. Is anyone able to successfully integrate dataflow version 2.3.0 above with keycloak ( not UAA)?. Also, I am using keycloak for SSO and no user registration required.

The configurations are changed from the version 2.3.0 which is not documented in the dataflow documentations. I have added only the keycloak related configuration in github https://github.com/ChimbuChinnadurai/spring-cloud-dataflow-keycloak-integration

Related

Problems trying to work around WebSecurityConfigurerAdapter deprecation using Spring Boot 2.7.5

When updating spring boot version 2.7.5 I noticed that the WebSecurityConfigurerAdapter class was deprecated in this version.
I followed the steps as described in section 2.2 on article on Baeldung
to customize my application's authentication rules, but the filterChain method is not even being called during application startup, as with the "configure" function using spring boot version 2.2.3.
Can anyone help me?
Below I show the before and after of my changes.
Before
#Configuration
#EnableWebSecurity
#EnableGlobalMethodSecurity(prePostEnabled = true)
class SecurityConfiguration : WebSecurityConfigurerAdapter() {
override fun configure(http: HttpSecurity) {
val tokenTypes: List<TokenType> = mapper.readValue(jsonTokenTypes, Array<TokenType>::class.java).toList()
http.csrf().disable()
.authorizeRequests()
.antMatchers("/graphql").permitAll()
.and()
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS)
.and()
.addFilterBefore(
AuthFilter.create(keySet, tokenTypes),
RequestHeaderAuthenticationFilter::class.java
)
}
}
After
#Configuration
#EnableWebSecurity
#EnableGlobalMethodSecurity(prePostEnabled = true)
class SecurityConfiguration() {
#Value("\${vehicle.op.jwk.key-set}")
private lateinit var keySet: List<String>
#Value("\${vehicle.op.jwt.token-types}")
private lateinit var jsonTokenTypes: String
protected val mapper = jacksonObjectMapper()
#Bean
fun filterChain(http: HttpSecurity): SecurityFilterChain {
val tokenTypes: List<TokenType> = mapper.readValue(jsonTokenTypes, Array<TokenType>::class.java).toList()
http.csrf().disable()
.authorizeRequests()
.antMatchers("/graphql").permitAll()
.and()
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS)
.and()
.addFilterBefore(
AuthFilter.create(keySet, tokenTypes),
RequestHeaderAuthenticationFilter::class.java
)
return http.build()
}
Application starts up normally, as shown in the log below:
13:22:33: Executing 'bootRun -Dspring.profiles.active=homolog'...
> Task :checkApolloVersions UP-TO-DATE
> Task :generateMainServiceApolloSources NO-SOURCE
> Task :compileKotlin UP-TO-DATE
> Task :compileJava NO-SOURCE
> Task :processResources UP-TO-DATE
> Task :classes UP-TO-DATE
> Task :bootRunMainClassName UP-TO-DATE
> Task :bootRun __ __ _ _ ___________ | \/ | ___ | |__ (_)___ \ \ \ \ | |\/| |/ _ \| '_ \| | / / \ \ \ \ | | | | (_) | |_) | | / / ) ) ) ) |_| |_|\___/|_.__/|_|/_/ / / / /
===========================/_/_/_/ :: my_application :: (vlatest)
2022-12-06 13:22:37.312 INFO 29076 --- [ main] i.company.op.vehicle.VehicleApplicationKt : Starting VehicleApplicationKt using Java 11.0.16 on DESKTOP-07SSK0A with PID 29076 (C:\company\GitHub\my_application\build\classes\kotlin\main started by admin in C:\company\GitHub\my_application) 2022-12-06 13:22:37.316 INFO 29076 --- [ main] i.company.op.vehicle.VehicleApplicationKt : No active profile set, falling back to 1 default profile: "default" 2022-12-06 13:22:37.816 INFO 29076 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode. 2022-12-06 13:22:37.883 INFO 29076
--- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 62 ms. Found 4 JPA repository interfaces. 2022-12-06 13:22:38.065 INFO 29076 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=c811da27-aff3-39ab-b4ee-d6bb20987e72 2022-12-06 13:22:38.602 INFO 29076 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 9090 (http) 2022-12-06 13:22:38.611 INFO 29076 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat] 2022-12-06 13:22:38.612 INFO 29076 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.68] 2022-12-06 13:22:38.718 INFO 29076 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext 2022-12-06 13:22:38.719 INFO 29076 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1351 ms 2022-12-06 13:22:38.872 INFO 29076 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting... 2022-12-06 13:22:39.037 INFO 29076 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed. 2022-12-06 13:22:39.507 INFO 29076 --- [ main] liquibase.executor.jvm.JdbcExecutor : SELECT COUNT(*) FROM public.liq_db_changelog_lock 2022-12-06 13:22:39.519 INFO 29076 --- [ main] liquibase.executor.jvm.JdbcExecutor : SELECT COUNT(*) FROM public.liq_db_changelog_lock 2022-12-06 13:22:39.520 INFO 29076 --- [ main] liquibase.executor.jvm.JdbcExecutor : SELECT LOCKED FROM public.liq_db_changelog_lock WHERE ID=1 2022-12-06 13:22:39.533 INFO 29076 --- [ main] l.lockservice.StandardLockService : Successfully acquired change log lock 2022-12-06 13:22:39.545 INFO 29076 --- [ main] liquibase.changelog.DatabaseChangeLog : Reading resource: db/changelog/202210050955-changelog.sql 2022-12-06 13:22:39.552 INFO 29076 --- [ main] liquibase.changelog.DatabaseChangeLog : Reading resource: db/changelog/202210051005-changelog.sql 2022-12-06 13:22:39.561 INFO 29076 --- [ main] liquibase.changelog.DatabaseChangeLog : Reading resource: db/changelog/202210141724-changelog.sql 2022-12-06 13:22:39.569 INFO 29076 --- [ main] liquibase.changelog.DatabaseChangeLog : Reading resource: db/changelog/202210310837-changelog.sql 2022-12-06 13:22:39.653 INFO 29076 --- [ main] liquibase.executor.jvm.JdbcExecutor : SELECT MD5SUM FROM public.liq_db_changelog WHERE MD5SUM IS NOT NULL LIMIT 1 2022-12-06 13:22:39.657 INFO 29076 --- [ main] liquibase.executor.jvm.JdbcExecutor : SELECT COUNT(*) FROM public.liq_db_changelog 2022-12-06 13:22:39.659 INFO 29076 --- [ main] l.c.StandardChangeLogHistoryService : Reading from public.liq_db_changelog 2022-12-06 13:22:39.659 INFO 29076 --- [ main] liquibase.executor.jvm.JdbcExecutor : SELECT * FROM public.liq_db_changelog ORDER BY DATEEXECUTED ASC, ORDEREXECUTED ASC 2022-12-06 13:22:39.683 INFO 29076 --- [ main] l.lockservice.StandardLockService : Successfully released change log lock 2022-12-06 13:22:39.831 INFO 29076 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default] 2022-12-06 13:22:39.911 INFO 29076 --- [ main] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.6.12.Final 2022-12-06 13:22:40.122 INFO 29076 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.2.Final} 2022-12-06 13:22:40.242 INFO 29076
--- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.PostgreSQL9Dialect 2022-12-06 13:22:40.651 INFO 29076 --- [ main] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform] 2022-12-06 13:22:40.658 INFO 29076 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default' 2022-12-06 13:22:42.695 INFO 29076 --- [ main] s.b.a.g.s.GraphQlWebMvcAutoConfiguration : GraphQL endpoint HTTP POST /graphql 2022-12-06 13:22:43.217 WARN 29076 --- [ main] .s.s.UserDetailsServiceAutoConfiguration :
Using generated security password: 6e231318-c400-4c42-bb52-079a429bd04a
This generated password is for development use only. Your security configuration must be updated before running your application in production.
2022-12-06 13:22:43.411 INFO 29076 --- [ main] o.s.s.web.DefaultSecurityFilterChain : Will secure any request with [org.springframework.security.web.session.DisableEncodeUrlFilter#4e92c6c2, org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter#71a18feb, org.springframework.security.web.context.SecurityContextPersistenceFilter#26aecf31, org.springframework.security.web.header.HeaderWriterFilter#693f9ab5, org.springframework.security.web.csrf.CsrfFilter#197d6cc9, org.springframework.security.web.authentication.logout.LogoutFilter#286f8e90, org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#327fd5c9, org.springframework.security.web.authentication.ui.DefaultLoginPageGeneratingFilter#3d1b6816, org.springframework.security.web.authentication.ui.DefaultLogoutPageGeneratingFilter#66032b8d, org.springframework.security.web.authentication.www.BasicAuthenticationFilter#70a9f4b7, org.springframework.security.web.savedrequest.RequestCacheAwareFilter#1abacff3, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter#4a3d4cd2, org.springframework.security.web.authentication.AnonymousAuthenticationFilter#7c1a5092, org.springframework.security.web.session.SessionManagementFilter#3f04847e, org.springframework.security.web.access.ExceptionTranslationFilter#76e56b17, org.springframework.security.web.access.intercept.FilterSecurityInterceptor#169f4152] 2022-12-06 13:22:43.478 INFO 29076 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 9090 (http) with context path '' 2022-12-06 13:22:43.488 INFO 29076
--- [ main] i.company.op.vehicle.VehicleApplicationKt : Started VehicleApplicationKt in 6.557 seconds (JVM running for 6.906)
Originally my application validates only the Bearer Token given in the request header, and after upgrade spring boot version now it requires a user/password authentication.

How to reduce the spring startup time

We are trying to deploy our spring boot application into AWS Lamda. While triggering an API through API gateway it is taking more time(28 to 30sec) to start up so I am getting timeout error as a response. And we configured Lamda memory as 512 MB.
Tried with the below changes as well:
Removed Unused dependencies from pom file.
Made static configuration for database connection.
Configured spring.jpa.hibernate.ddl-auto as none for avoiding the database initialization.
With spring.main.lazy-initialization=true
By #EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class})
Any suggestions would be welcome.
Adding logs:
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot ::
2021-09-27 09:08:38.938 INFO 1 --- [ main] lambdainternal.LambdaRTEntry : Starting LambdaRTEntry using Java 1.8.0_302 on 169.254.30.181 with PID 1 (/var/runtime/lib/LambdaJavaRTEntry-1.0.jar started by sbx_user1051 in /)
2021-09-27 09:08:38.941 INFO 1 --- [ main] lambdainternal.LambdaRTEntry : No active profile set, falling back to default profiles: default
2021-09-27 09:08:43.719 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2021-09-27 09:08:44.748 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 983 ms. Found 20 JPA repository interfaces.
2021-09-27 09:08:47.871 INFO 1 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2021-09-27 09:08:48.085 INFO 1 --- [ main] org.hibernate.Version : HHH000412: Hibernate ORM core version [WORKING]
2021-09-27 09:08:48.906 INFO 1 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
2021-09-27 09:08:49.322 INFO 1 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2021-09-27 09:08:50.697 INFO 1 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2021-09-27 09:08:50.779 INFO 1 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.PostgreSQLDialect
2021-09-27 09:08:57.684 INFO 1 --- [ main] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2021-09-27 09:08:57.759 INFO 1 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2021-09-27 09:09:07.124 INFO 1 --- [ main] lambdainternal.LambdaRTEntry : Started LambdaRTEntry in 30.106 seconds (JVM running for 31.393)
2021-09-27 09:09:07.188 INFO 1 --- [ main] c.f.c.c.BeanFactoryAwareFunctionRegistry : Looking up function 'function' with acceptedOutputTypes: []
2021-09-27 09:09:07.190 WARN 1 --- [ main] c.f.c.c.BeanFactoryAwareFunctionRegistry : !!! Failed to discover function 'function' in function catalog. Function available in catalog are: [lamdaFunction, functionRouter]
2021-09-27 09:09:07.190 INFO 1 --- [ main] c.f.c.c.BeanFactoryAwareFunctionRegistry : Looking up function 'consumer' with acceptedOutputTypes: []
2021-09-27 09:09:07.190 WARN 1 --- [ main] c.f.c.c.BeanFactoryAwareFunctionRegistry : !!! Failed to discover function 'consumer' in function catalog. Function available in catalog are: [lamdaFunction, functionRouter]
2021-09-27 09:09:07.191 INFO 1 --- [ main] c.f.c.c.BeanFactoryAwareFunctionRegistry : Looking up function 'supplier' with acceptedOutputTypes: []
2021-09-27 09:09:07.191 WARN 1 --- [ main] c.f.c.c.BeanFactoryAwareFunctionRegistry : !!! Failed to discover function 'supplier' in function catalog. Function available in catalog are: [lamdaFunction, functionRouter]
2021-09-27 09:09:07.192 INFO 1 --- [ main] c.f.c.c.BeanFactoryAwareFunctionRegistry : Looking up function 'lamdaFunction' with acceptedOutputTypes: []
Based on my experience in general the warm up time is longer for Spring Boot services but if you have more requests coming in a short period, from the second call it should be faster.
If your client can wait a little bit more than 30 seconds, then you can increase the timeout for the Lambda function itself: Lambda/Function/General Configuration/Timeout.
Be careful with connecting to a DB from Lambda, because as Lambda scales out, you may run out of DB connections: https://solidstudio.io/blog/aws-handle-database-connection
For first time startup, generally Spring Boot with Hibernate does not go well with quick startup environments like Lambdas. There are few techniques which can be tried as mentioned here or an alternate solution like Quarkus is better fit. Many people have also gone the route of perpetually warming up the lambdas by pinging.
Your connection-pool (HikariCP) setup is quite fast so it does not look like database connection issue
2021-09-27 09:08:49.322 INFO 1 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2021-09-27 09:08:50.697 INFO 1 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
Most of your time seems to be spending on loading Spring classes and setup (approx 5s)
2021-09-27 09:08:38.941 INFO 1 --- [ main] lambdainternal.LambdaRTEntry : No active profile set, falling back to default profiles: default
2021-09-27 09:08:43.719 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT
And also Hibernate setup ( which scans the entities, creates auto-generated queries etc.) - approx 10s
2021-09-27 09:08:47.871 INFO 1 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default] 2021-09-27 09:08:48.085 INFO 1 --- [ main] org.hibernate.Version : HHH000412: Hibernate ORM core version [WORKING] 2021-09-27 09:08:48.906 INFO 1 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
2021-09-27 09:08:49.322 INFO 1 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2021-09-27 09:08:50.697 INFO 1 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2021-09-27 09:08:50.779 INFO 1 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.PostgreSQLDialect 2021-09-27 09:08:57.684 INFO 1 --- [ main] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2021-09-27 09:08:57.759 INFO 1 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
Hope you are not using schema auto-update feature of hibernate because then it spends some time there as well.

status:401 unauthorized in postman

Iam working in springboot application and iam trying to save the data in database, code is executing properly and not getting any error during execution but when iam trying to post the url in postman iam getting status: 401 unauthorized
any quick suggestion
console
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.3.4.RELEASE)
2020-12-08 17:34:07.094 INFO 7236 --- [ main] c.regestration.RegestrationApplication : Starting RegestrationApplication on Darshan with PID 7236 (C:\Users\admin\Desktop\regestration\target\classes started by admin in C:\Users\admin\Desktop\regestration)
2020-12-08 17:34:07.111 INFO 7236 --- [ main] c.regestration.RegestrationApplication : No active profile set, falling back to default profiles: default
2020-12-08 17:34:08.584 INFO 7236 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFERRED mode.
2020-12-08 17:34:08.803 INFO 7236 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 202ms. Found 1 JPA repository interfaces.
2020-12-08 17:34:10.751 INFO 7236 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8085 (http)
2020-12-08 17:34:10.788 INFO 7236 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2020-12-08 17:34:10.788 INFO 7236 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.38]
2020-12-08 17:34:11.158 INFO 7236 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2020-12-08 17:34:11.158 INFO 7236 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 3827 ms
2020-12-08 17:34:11.617 INFO 7236 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2020-12-08 17:34:11.815 INFO 7236 --- [ task-1] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2020-12-08 17:34:11.935 WARN 7236 --- [ main] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2020-12-08 17:34:12.006 INFO 7236 --- [ task-1] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.4.21.Final
2020-12-08 17:34:13.075 INFO 7236 --- [ task-1] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.0.Final}
2020-12-08 17:34:13.554 INFO 7236 --- [ task-1] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2020-12-08 17:34:14.050 INFO 7236 --- [ main] .s.s.UserDetailsServiceAutoConfiguration :
Using generated security password: 7406d0eb-72dc-4ce4-a8cc-220d3c523098
2020-12-08 17:34:14.273 INFO 7236 --- [ main] o.s.s.web.DefaultSecurityFilterChain : Creating filter chain: any request, [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter#574cd322, org.springframework.security.web.context.SecurityContextPersistenceFilter#55e2fe3c, org.springframework.security.web.header.HeaderWriterFilter#64f1fd08, org.springframework.security.web.csrf.CsrfFilter#7187bac9, org.springframework.security.web.authentication.logout.LogoutFilter#5c8e67b9, org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#1174a305, org.springframework.security.web.authentication.ui.DefaultLoginPageGeneratingFilter#43e1692f, org.springframework.security.web.authentication.ui.DefaultLogoutPageGeneratingFilter#45c2e0a6, org.springframework.security.web.authentication.www.BasicAuthenticationFilter#1f3165e7, org.springframework.security.web.savedrequest.RequestCacheAwareFilter#12c60152, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter#692e028d, org.springframework.security.web.authentication.AnonymousAuthenticationFilter#119c745c, org.springframework.security.web.session.SessionManagementFilter#282ffbf5, org.springframework.security.web.access.ExceptionTranslationFilter#6c15e8c7, org.springframework.security.web.access.intercept.FilterSecurityInterceptor#3a08078c]
2020-12-08 17:34:14.874 INFO 7236 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8085 (http) with context path ''
2020-12-08 17:34:14.884 INFO 7236 --- [ main] DeferredRepositoryInitializationListener : Triggering deferred initialization of Spring Data repositories…
2020-12-08 17:34:14.889 INFO 7236 --- [ task-1] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2020-12-08 17:34:14.948 INFO 7236 --- [ task-1] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL5InnoDBDialect
2020-12-08 17:34:18.480 INFO 7236 --- [ task-1] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2020-12-08 17:34:18.495 INFO 7236 --- [ task-1] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2020-12-08 17:34:18.881 INFO 7236 --- [ main] DeferredRepositoryInitializationListener : Spring Data repositories initialized!
2020-12-08 17:34:18.890 INFO 7236 --- [ main] c.regestration.RegestrationApplication : Started RegestrationApplication in 13.562 seconds (JVM running for 19.799)
2020-12-08 17:34:42.030 INFO 7236 --- [nio-8085-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'
2020-12-08 17:34:42.031 INFO 7236 --- [nio-8085-exec-1] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
2020-12-08 17:34:42.050 INFO 7236 --- [nio-8085-exec-1] o.s.web.servlet.DispatcherServlet : Completed initialization in 19 ms
controller
package com.regestration.controller;
import java.util.HashMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.regestration.repository.Repository;
import com.regestration.user.User;
#RestController
public class Controller {
#Autowired
Repository repo;
#RequestMapping(value="/saveReg", method= RequestMethod.POST)
public HashMap<String, Object>saveRegestration(#RequestBody User user){
HashMap<String, Object> map = new HashMap<String, Object>();
repo.save(user);
map.put("code", "200");
map.put("code", "saved");
return map;
}
}
application.properties
spring.datasource.url= jdbc:mysql://localhost:3306/myshadi?useSSL=false
spring.datasource.username= root
spring.datasource.password= root
spring.jpa.properties.hibernate.dialect= org.hibernate.dialect.MySQL5InnoDBDialect
# Hibernate ddl auto (create, create-drop, validate, update)
spring.jpa.hibernate.ddl-auto= update
server.port=8085
Spring is activating by default the security.
See line : Using generated security password: 7406d0eb-72dc-4ce4-a8cc-220d3c523098.
You have to inactivate the security if you don't need it : Spring boot Security Disable security

decrypt git password in config-server not working

I am using a spring cloud config server. I try to store my git password encrypted in the applicayion.yml file. When I start my config server I get the error message 'not authorized'.
I do not understand what you really need to use the encrypted password. I thought it was working out of the box. I can do /encrypt en /decrypt on the url of the config server.
If I use the git password as plain text it is working fine.
What am I doing wrong ? Which dependencies do you nees. I also tried to put the JCE jar files but that does not seem to work.
thank
Jon
My application.yml file:
spring:
cloud:
config:
server:
git:
uri: <my-git-repo>
username: my-username
password: '{cypher}ce544e1c6754678b814c00080e622b6001a33194c45ba38351a40aa423c22f46'
my boostrap.yml file :
encrypt:
key: mysecret
here is the error message
2020-02-24 13:12:28.969 INFO 6956 --- [ main] o.s.s.web.DefaultSecurityFilterChain : Creating filter chain: any request, [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter#3b8ec001, org.springframework.security.web.context.SecurityContextPersistenceFilter#4e642ee1, org.springframework.security.web.header.HeaderWriterFilter#2489e84a, org.springframework.security.web.csrf.CsrfFilter#5e5aafc6, org.springframework.security.web.authentication.logout.LogoutFilter#338766de, org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#2a43e0ac, org.springframework.security.web.authentication.ui.DefaultLoginPageGeneratingFilter#4833eff3, org.springframework.security.web.authentication.ui.DefaultLogoutPageGeneratingFilter#1e95b653, org.springframework.security.web.authentication.www.BasicAuthenticationFilter#6d8796c1, org.springframework.security.web.savedrequest.RequestCacheAwareFilter#2fd954f, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter#2676dc05, org.springframework.security.web.authentication.AnonymousAuthenticationFilter#6f6c6077, org.springframework.security.web.session.SessionManagementFilter#62b93086, org.springframework.security.web.access.ExceptionTranslationFilter#41b13f3d, org.springframework.security.web.access.intercept.FilterSecurityInterceptor#6d2a2560]
2020-02-24 13:12:30.221 INFO 6956 --- [ main] o.s.b.a.e.web.EndpointLinksResolver : Exposing 15 endpoint(s) beneath base path '/actuator'
2020-02-24 13:12:30.284 INFO 6956 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8888 (http) with context path ''
2020-02-24 13:12:30.869 INFO 6956 --- [ main] c.e.c.SpringCloudConfigServerApplication : Started SpringCloudConfigServerApplication in 5.161 seconds (JVM running for 5.998)
2020-02-24 13:12:31.349 INFO 6956 --- [on(1)-10.0.75.1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'
2020-02-24 13:12:31.349 INFO 6956 --- [on(1)-10.0.75.1] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
2020-02-24 13:12:31.353 INFO 6956 --- [on(1)-10.0.75.1] o.s.web.servlet.DispatcherServlet : Completed initialization in 4 ms
2020-02-24 13:12:33.567 WARN 6956 --- [on(2)-10.0.75.1] .c.s.e.MultipleJGitEnvironmentRepository : Error occured cloning to base directory.
org.eclipse.jgit.api.errors.TransportException: https://my-repo: not authorized
at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:254) ~[org.eclipse.jgit-5.1.3.201810200350-r.jar:5.1.3.201810200350-r]
at org.eclipse.jgit.api.CloneCommand.fetch(CloneCommand.java:306) ~[org.eclipse.jgit-5.1.3.201810200350-r.jar:5.1.3.201810200350-r]
at org.eclipse.jgit.api.CloneCommand.call(CloneCommand.java:200) ~[org.eclipse.jgit-5.1.3.201810200350-r.jar:5.1.3.201810200350-r]
at org.springframework.cloud.config.server.environment.JGitEnvironmentRepository.cloneToBasedir(JGitEnvironmentRepository.java:589) [spring-cloud-config-server-2.2.1.RELEASE.jar:2.2.1.RELEASE]
at org.springframework.cloud.config.server.environment.JGitEnvironmentRepository.copyRepository(JGitEnvironmentRepository.java:564) [spring-cloud-config-server-2.2.1.RELEASE.jar:2.2.1.RELEASE]
at org.springframework.cloud.config.server.environment.JGitEnvironmentRepository.createGitClient(JGitEnvironmentRepository.java:547) [spring-cloud-config-server-2.2.1.RELEASE.jar:2.2.1.RELEASE]

Run different profiles on Spring

I have an application where I need to run 3 profiles (united-states, france and vietnam) as shown in application.yml file shown below. These 3 profiles should come under registered service in my Eureka server that is running on port 9000.
I have run java -jar -Dspring.profiles.active=united-states xxx.jar to run my Spring application, but my Spring application defaults to port 8761 and my service is not registered in Eureka server.
---
# This default profile is used when running a single instance completely standalone:
spring:
profiles: default
server:
port: 9000
eureka:
instance:
hostname: my-eureka-server.com
client:
registerWithEureka: false
fetchRegistry: false
serviceUrl:
defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
# united-states, france, and vietnam illustrate running 3 intercommunicating instances.
# This example has them running side-by-side on localhost
# -- which is unrealistic in production
# -- but does illustrate how multiple instances collaborate.
#
# Run by opening 3 separate command prompts:
# java -jar -Dspring.profiles.active=united-states SpringCloudServiceRegistrationEurekaServer.jar
# java -jar -Dspring.profiles.active=france SpringCloudServiceRegistrationEurekaServer.jar
# java -jar -Dspring.profiles.active=vietnam SpringCloudServiceRegistrationEurekaServer.jar
---
spring:
profiles: united-states
application:
name: eureka-server-clustered # ==> This is Service-Id
server:
port: 9001
eureka:
instance:
hostname: my-eureka-server-us.com
client:
registerWithEureka: true
fetchRegistry: true
serviceUrl:
defaultZone: http://my-eureka-server-fr.com:9002/eureka/,http://my-eureka-server-vn.com:9003/eureka/
---
spring:
profiles: france
application:
name: eureka-server-clustered # ==> This is Service-Id
server:
port: 9002
eureka:
instance:
hostname: my-eureka-server-fr.com
client:
registerWithEureka: true
fetchRegistry: true
serviceUrl:
defaultZone: http://my-eureka-server-us.com:9001/eureka/,http://my-eureka-server-vn.com:9003/eureka/
---
spring:
profiles: vietnam
application:
name: eureka-server-clustered # ==> This is Service-Id
server:
port: 9003
eureka:
instance:
hostname: my-eureka-server-vn.com
client:
registerWithEureka: true
fetchRegistry: true
serviceUrl:
defaultZone: http://my-eureka-server-us.com:9001/eureka/,http://my-eureka-server-fr.com:9002/eureka/
Log:
2019-04-16 06:41:10.681 INFO 31061 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$75804a9c] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.1.4.RELEASE)
2019-04-16 06:41:11.142 INFO 31061 --- [ main] rviceRegistrationEurekaServerApplication : The following profiles are active: united-states
2019-04-16 06:41:12.264 INFO 31061 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data repositories in DEFAULT mode.
2019-04-16 06:41:12.284 INFO 31061 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 11ms. Found 0 repository interfaces.
2019-04-16 06:41:12.477 WARN 31061 --- [ main] o.s.boot.actuate.endpoint.EndpointId : Endpoint ID 'service-registry' contains invalid characters, please migrate to a valid format.
2019-04-16 06:41:12.825 INFO 31061 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=aedccd61-e8da-3db8-953a-28c197e2743c
2019-04-16 06:41:13.026 INFO 31061 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$5966479f] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-04-16 06:41:13.076 INFO 31061 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$75804a9c] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-04-16 06:41:13.530 INFO 31061 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8761 (http)
2019-04-16 06:41:13.573 INFO 31061 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2019-04-16 06:41:13.574 INFO 31061 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.17]
2019-04-16 06:41:13.690 INFO 31061 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2019-04-16 06:41:13.690 INFO 31061 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2525 ms
2019-04-16 06:41:13.887 WARN 31061 --- [ main] c.n.c.sources.URLConfigurationSource : No URLs will be polled as dynamic configuration sources.
2019-04-16 06:41:14.683 INFO 31061 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2019-04-16 06:41:15.126 INFO 31061 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2019-04-16 06:41:15.230 INFO 31061 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
2019-04-16 06:41:15.316 INFO 31061 --- [ main] org.hibernate.Version : HHH000412: Hibernate Core {5.3.9.Final}
2019-04-16 06:41:15.320 INFO 31061 --- [ main] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found
2019-04-16 06:41:15.484 INFO 31061 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.0.4.Final}
2019-04-16 06:41:15.769 INFO 31061 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
2019-04-16 06:41:16.039 INFO 31061 --- [ main] o.h.t.schema.internal.SchemaCreatorImpl : HHH000476: Executing import script 'org.hibernate.tool.schema.internal.exec.ScriptSourceInputNonExistentImpl#6c841199'
2019-04-16 06:41:16.043 INFO 31061 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2019-04-16 06:41:16.068 WARN 31061 --- [ main] c.n.c.sources.URLConfigurationSource : No URLs will be polled as dynamic configuration sources.
2019-04-16 06:41:16.362 INFO 31061 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2019-04-16 06:41:16.436 WARN 31061 --- [ main] aWebConfiguration$JpaWebMvcConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2019-04-16 06:41:17.084 INFO 31061 --- [ main] o.s.b.a.e.web.EndpointLinksResolver : Exposing 2 endpoint(s) beneath base path '/actuator'
2019-04-16 06:41:17.226 INFO 31061 --- [ main] o.s.c.n.eureka.InstanceInfoFactory : Setting initial instance status as: STARTING
2019-04-16 06:41:17.290 INFO 31061 --- [ main] o.s.c.n.e.s.EurekaServiceRegistry : Registering application EUREKA-SERVER with eureka with status UP
2019-04-16 06:41:17.353 INFO 31061 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8761 (http) with context path ''
2019-04-16 06:41:17.354 INFO 31061 --- [ main] .s.c.n.e.s.EurekaAutoServiceRegistration : Updating port to 8761
2019-04-16 06:41:17.360 INFO 31061 --- [ main] rviceRegistrationEurekaServerApplication : Started SpringCloudServiceRegistrationEurekaServerApplication in 7.941 seconds (JVM running for 8.624)
Note: I am using Intellij on Ubuntu and had configured my /etc/hosts file to include these hosts:
127.0.0.1 my-eureka-server.com
127.0.0.1 my-eureka-server-us.com
127.0.0.1 my-eureka-server-fr.com
127.0.0.1 my-eureka-server-vn.com
Your app is running as Eureka Server. If that's not what you expect, disable #EnableEurekaServer annotation if you have it on your #SpringBootApplication annotated class

Resources