I have integrated Apache Shiro with Spring Boot with Spring Data JPA. The Spring Boot project is in this GitHub repo.
The problem is when I run and try to authenticate the app I get the following error
roleAdmin.getId() 1: null
roleAdmin.getId() 2: 3
Current user is not authenticated.
2016-08-13 09:49:45.715 WARN 10528 --- [lication Thread] o.h.engine.jdbc.spi.SqlExceptionHelper : SQL Error: 0, SQLState: S0022
2016-08-13 09:49:45.716 ERROR 10528 --- [lication Thread] o.h.engine.jdbc.spi.SqlExceptionHelper : Column 'id' not found.
Authentication failed for token submission [org.apache.shiro.authc.UsernamePasswordToken - yunus, rememberMe=false]. Possible unexpected error? (Typical or expected login exceptions should extend from AuthenticationException).
It completely fails to authenticate, I managed to create this repo to elaborate my problem. Check it out.
Solutions and criticism are highly acceptable.
Update
If any extra info is needed to clarify my question, just ask
Your error message is indicative of the problem, which lies in your User repository's
@Query
definition:As you can see, you're selecting only the username, instead of selecting every column. Since you're using Spring Data JPA, you don't really need the
@Query
at all, it's enough to just say:Your other problem, however, is how you compare the passwords in your custom realm. The password coming from the DB will be encrypted, meaning that you cannot just say
You'll have to compare the passwords using the
DefaultPasswordService
by calling itspasswordsMatch
method and, since you'e just verified the paswords yourself, you should useAllowAllCredentialsMatcher
in your realm: