on 2019 Feb 14 11:34 AM
Hello Experts,
I've a Spring Boot application deployed to HCP Tomcat 8.
I'm trying the get the authenticated user name:
request.getUserPrincipal().getName() but request.getUserPrincipal() is null.
I tried adding
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
Local Tomcat works but the app is "hanging" ('starting' and then fails) when trying to start it in the cloud (I can deploy it but not start it).
I'm expecting that the HCP runtime Tomcat will get the username from SAP Identity Provider.
Any experience on the right settings to get this to work?
Regards,
Omri
Request clarification before answering.
Hi Omri,
Please read my blog on the topic of running Spring applications on SCP-Neo.
To get the user on SCP you could use the following API:
ScpCfUser user=(ScpCfUser)UserAccessor.getCurrentUser();
I've also written a Spring application that implements spring security on Neo - which is a bit different than what you will find on Neo's SDK samples.
https://github.com/ivanmir/coil.spring.hcp.auth
In my PoV, you should never run your application on a Tomcat server installed locally. You should use the Neo SDK to deploy and perform unit testing of your app locally. Only then, when you have figured out all dependencies and integrations via the SDK you can safely deploy to Neo. If you use a local Tomcat installation you will not be mimicking the cloud environment - thus you will start to face a lot of issues. Not to mention the delay between changing your code and deploying to perform unit testing. The SDK in that sense is a much faster way to develop. If you don't like to develop on Eclipse, please use maven. There is a main pom.xml artifact on the samples folder which implements the same approach you see on Eclipse and will deploy and test your application on a controlled environment.
Best regards,
Ivan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Muito obrigado Ivan, você não sabe o que venho tentando proteger o aplicativo com spring boot.
Hi Ivan,
Thanks!
As far as I understand 'ScpCfUser' is for CF and not for Neo. Am I right?
Your GitHub code works fine on Neo! (it's not standard and I'll use it as fallback if standard code from SDK won't work).
I read your blog and I totally agree that using Neo SDK is the correct way for developing.
However, no matter what I do (Spring Boot, simple servlet) each time I try to run in Neo tomcat I get 404 not found.
Project name is 'demo' and mapping is 'greeting'.
I tried:
http://localhost:8994/demo/greeting
http://localhost:8994/demo
http://localhost:8994/greeting
http://localhost:8994/demo-application/greeting
Neo SDK version is 3.74.20.
How can I solve it?
Regards,
Omri
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
24 | |
22 | |
8 | |
5 | |
5 | |
4 | |
4 | |
4 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.