Please ensure that at least one realm can authenticate these tokens

落爺英雄遲暮 提交于 2019-12-03 17:35:35

Looks like it is expected behavior.

If you look at the javadoc for ModularRealmAuthenticator:

 * @throws AuthenticationException if the user could not be authenticated or the user is denied authentication
 *                                 for the given principal and credentials.
 */
protected AuthenticationInfo doAuthenticate(AuthenticationToken authenticationToken) throws AuthenticationException {

If you are having problems with the exception, you might need to change the code that calls the authentication to expect this exception.


Left for other searches:

You might have a missing supports method in your TokenAuthorizingRealm class.

Something like

@Override
public boolean supports(AuthenticationToken token) {
    return token instanceof BearerAuthenticationToken;
}

should be present.

This discussion help me solve a similar problem. I wanted to authenticate a user by the application itself, not using any Shiro default implementation. To do that we must subclass AuthenticatingRealm, override doGetAuthenticationInfo and declare this realm as the validation one.

public class PasswordAuthorizingRealm extends AuthenticatingRealm {

    @Override
    protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authenticationToken) throws AuthenticationException {

In Shiro.ini:

passwordValidatorRealm = my.PasswordAuthorizingRealm
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!