MChan
MChan

Reputation: 7162

Spring security no password

I am trying to have a login form in my Spring MVC/ Hibernate app, where users can login with only a valid username, (no password) is required. I am currently using Spring Security but it required a user name and password, so I was wondering if it is possible to allow login with no password? and if yes how? Any sample, link to tutorial/ example is highly appreciated. Thanks

Upvotes: 1

Views: 1878

Answers (1)

rocky
rocky

Reputation: 5004

you can try to do it with

Authentication auth = new UsernamePasswordAuthenticationToken(user, null, user.getAuthorities());

SecurityContextHolder.getContext().setAuthentication(auth);

null here is password, but not required.

Upvotes: -1

Related Questions