All Downloads are FREE. Search and download functionalities are using the official Maven repository.

top.zenyoung.security.webflux.AuthenticationManager Maven / Gradle / Ivy

There is a newer version: 2.0.2
Show newest version
package top.zenyoung.security.webflux;

import org.springframework.http.HttpMethod;
import org.springframework.security.authentication.ReactiveAuthenticationManager;
import top.zenyoung.security.model.LoginReqBody;
import top.zenyoung.security.model.LoginRespBody;
import top.zenyoung.security.model.UserPrincipal;
import top.zenyoung.security.token.JwtTokenGenerator;
import top.zenyoung.security.token.TokenGenerator;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;

/**
 * 认证管理器接口
 *
 * @author yangyong
 * @version 1.0
 *  2020/3/20 5:59 下午
 **/
public interface AuthenticationManager extends ReactiveAuthenticationManager {

    /**
     * 获取令牌
     *
     * @return 令牌
     */
    @Nonnull
    default TokenGenerator getTokenGenerator() {
        return new JwtTokenGenerator();
    }

    /**
     * 获取登录请求方法
     *
     * @return 登录请求方法
     */
    @Nonnull
    default HttpMethod getLoginMethod() {
        return HttpMethod.POST;
    }

    /**
     * 获取登录请求地址集合
     *
     * @return 登录请求地址集合
     */
    @Nonnull
    default String[] getLoginUrls() {
        return new String[0];
    }

    /**
     * 获取白名单Urls.
     *
     * @return 白名单Urls.
     */
    @Nullable
    default String[] getWhiteUrls() {
        return null;
    }

    /**
     * 获取用户登录请求报文类型
     *
     * @return 用户登录请求报文类型
     */
    default Class getLoginReqBodyClass() {
        return LoginReqBody.class;
    }

    /**
     * 获取返回登录用户数据
     *
     * @param userPrincipal 用户数据
     * @return 返回登录用户数据
     */
    @Nonnull
    LoginRespBody getUserResp(@Nonnull final UserPrincipal userPrincipal);
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy