Grails spring security ldap plugin - spring

I am writing a project using Grails and Spring Security. I want to use LDAP for it. As such, I installed the spring-security-core and spring-security-LDAP plugins. I got the login to work for spring security. I also have LDAP running and configured in Grails. I would rather not post that source, but it has the needed springsecurity.ldap.contexts/search/authorities.
The problem is I can't get it to stop searching locally. If I try to use a name from LDAP, it fails, yet if I use one from bootstrap it works. I know this has been asked before, but I looked through the answer and got a 404 for some important parts. My question is nearly identical to this person's, Although, it would seem his issue was never resolved.

Related

Quarkus discovering of JAXRS-Endpoints

I'am currently trying to understand the discovering of JAXRS-Endpoints in Quarkus. My assumption is that they are automatically discovered and there is no need to register them. In addition I tried to import Endpoints from an other module/jar File. It is working to out of the box.
But than I tried to understand the order of discovering endpoints.
I tried to overwrite a jar file provided endpoint in my application, but it is not working. Therfore in my opinion there is a potential security problem, if any third party module can overwrite my endpoints. Has anyone the same problems and can provide me informations how to think about this problem? (My only solution is to write an own extension which removes all endpoints an add only the ones I want to have, but I think this is against the idea)
Thanks in advance!
Duplicate endpoint detection was added to RESTEasy Reactive in https://github.com/quarkusio/quarkus/pull/15037.
This means that from version 2.7.0.CR1 and on, Quarkus will fail the build if duplicate JAX-RS endpoints are defined (assuming you are using quarkus-resteasy-reactive).

How to set up a swagger-ui standalone server/application?

I would like to set up a standalone swagger-ui application, to view the different APIs from different servers in one central place.
In a second step I would like to customise swagger-ui to show multiple APIs at once.
I don't want to add swagger-ui to all the servers that provide swagger api-docs though.
To do so I would like to use spring boot and thought this should be an easy task. However, I have trouble getting it to work.
Here is what I did:
Generated a Spring Boot application using https://start.spring.io
included spring-boot-starter-web
added io.springfox:springfox-swagger-ui:2.3.1 dependency
When opening http://localhost:8080/swagger-ui.html I see a 404 error and UI seems broken:
Is there any reason for using Spring-boot instead of a simple web server for this?
See for example here with Nginx, including some basic authentication (pretty old link but still looking alright), or in the ReadMe of the swagger-ui github reposiory directly for easily serving with Connect/gulp-serve inside Docker (the setup can also be reproduced directly without Docker if wanted).
Also I have no idea why you're getting resources requested by the page on a different port... Just ask in case you still need help now on this topic.

The best web login approach

I am developing a jsp dynamic web project on eclipse.
I want to create an website with login functionality. I intend to store users' accounts and passwords in MySQL database. Of course, different users have different roles and rights to access different web pages. What is the best approach to implement it?
So far, I know these approaches:
1) Users enter accounts/passwords in login.jsp. LoginServlet then connects to MySQL database to check if it is correct. AuthenticationFilters will make sure only users with rights can access certain pages.
2) Use Role Based Authentication by declaring user roles in web.xml. I find this approach is not flexible, because I need to declare roles in advance.
3) Use HttpServletRequest's login/logout methods. I have not studied it.
Is my understanding correct? Could someone gives me some suggestions? Some clues would be very helpful!
Besides, I know that using POST alone to send passwords is not safe enough. Many websites suggest to use HTTPS connections. So if using HTTPS connections, does it affect the approach I choose to implement the login function?
Thanks!
--
Now, I know I need to use Spring. But Spring seems difficult for me... In Spring website I cant find out the link to download jar files. The user guide says I need to use Gradle or Maven, which I haven't used before, and have no idea why I need them. Besides, there are many Spring projects. Which one should I choose? Spring framework?
--
Have you looked into using Spring Security? It's built for just that. You don't need to be familiar with Spring but it may help.
Here are a couple of tutorials that use database authentication:
1: Spring Security Authentication and Authorization Example with Database Credentials
2: Spring Security Login Example with Database
Edit:
You don't have to Maven or Gradle. You can simply add the jars to your build path and they will work. The only projects you need to implement for the login to work is the Spring Framework and Spring Security.
To use Spring Security without Maven or Gradle:
Download the Spring Framework jars, unzip them, and add them to your project and build path. It's probably a good idea to find a hello world tutorial using Spring to get you started. A quick Google search should turn up many results.
After you have Spring implemented in your project, download the Spring Security jars, unzip those, and add them to your build path. The links to the tutorials that I previously posted will get you started. They may take a little while to go through and you may not understand exactly what is happening behind the scenes, but once you get it set up is works outstanding. I'm also not sure if you are using xml configuration or Java config but I believe those tutorials are for xml.
Spring Security was built so that it could be added to any project and have you up and running with basic configuration in about 15 minutes. After you get the basic login going (it will use the generic login form), you can search for how to implement your own custom login form, add permissions or restrictions to users and url patters, adding custom filters, etc. I encourage you to spend some time learning it as it is highly flexible and customizable.

Secure Spring REST Service using spring-security-oauth2 2.0.5.RELEASE

I have been searching for an example Spring Webservice which is being protected using oauth 2.0..
Looking around I found https://github.com/spring-projects/spring-security-oauth/tree/master/samples/oauth2 but there some files seems to be missing from the project.
Two things that I am looking for is :
When user authenticates, user name and password goes to /login.do , now I can not understand how this Servlet is being configured, if its not controller. web.xml is missing.
When I try to see how beans configured then applicationContext.xml is also missing. I am not able to find those files in order to see how things are configured.
Help Required :
Should I use annotation in order to configure my web service or xml configuration. I am willing to use the latest version, and leverage advanced configurations, for better security.
I have another Single page application ( HTML5 ) , which accesses data from this spring web service, which is being hosted on Google App Engine. My ultimate objective is to create a chrome plugin of (html5) pages and use my service from there..
Please suggest a better path so that I can achieve my objectives.
Best regards,
Shashank Pratap
Apologize for late reply.
1) Regarding Oauth2.0 implementation : Since GAE does not support Servlet 3.0 therefore, developer is restricted to servlet 2.5. Therefore I found that we are restricted to 1.0.5.RELEASE. I was able to configure it successfully.
Best Practice on GAE : Rather than following this approach, I would suggest others to use Google Endpoints. As it supports oauth2.0 as well as we can develop REST API relatively quickly.
Scale ability and Response time : Since I was using Spring dependency injection along with spring security, application responded slower than the combination of Google Endpoints and Google Juice, as juice does injection just in time, where as spring prepares everything as soon as new instance starts, which created problem for me.
2) Chrome Plugin is completely different story. :-)
Please correct if I am wrong.
Thanks,
Shashank Pratap

SAXParseException when running Spring 3 JUnit

I just upgraded to Spring 3, and attempted to run some JUnits to make sure everything was copacetic. It wasn't. I got a SAXParseException when loading the context... it complained:
Failed to read schema document 'http://www.springframework.org/schema/beans/spring-beans-2.0.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not .
My suspicion is that it couldn't access the XSD due to proxy configuration. Is there a way to make it stop trying so hard to validate it and just run the darn thing? :)
In all seriousness, though, I didn't have a problem when I was running under Spring 2, so I suspect that Spring 2 didn't bother to try to validate, but Spring 3 does. I was hoping there was a way to bypass that functionality.
One further clue... Since I couldn't run the JUnits, I went ahead and fired up the server (this is a web app), and everything seemed to go swimmingly. So that makes me think that Spring is just fine with my context files as they are.
Edit The same error occurs when using instead the Spring 3.0 schemas
It could be because you are using xsd of spring 2. You could try using http://www.springframework.org/schema/beans/spring-beans-3.0.xsd.
As it turns out, my problem was a result of re-bundling the spring jars into a single jar. Just using the separate jars worked fine for me.

Resources