mirror of
https://gitee.com/yadong.zhang/JustAuth.git
synced 2026-01-07 19:31:48 +08:00
69 lines
2.0 KiB
Java
69 lines
2.0 KiB
Java
package me.zhyd.oauth.request;
|
||
|
||
import me.zhyd.oauth.exception.AuthException;
|
||
import me.zhyd.oauth.model.AuthCallback;
|
||
import me.zhyd.oauth.model.AuthResponse;
|
||
import me.zhyd.oauth.model.AuthResponseStatus;
|
||
import me.zhyd.oauth.model.AuthToken;
|
||
|
||
/**
|
||
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
|
||
* @version 1.0
|
||
* @since 1.8
|
||
*/
|
||
public interface AuthRequest {
|
||
|
||
/**
|
||
* 返回认证url,可自行跳转页面
|
||
* <p>
|
||
* 不建议使用该方式获取授权地址,不带{@code state}的授权地址,容易受到csrf攻击。
|
||
* 建议使用{@link AuthDefaultRequest#authorize(String)}方法生成授权地址,在回调方法中对{@code state}进行校验
|
||
*
|
||
* @return 返回授权地址
|
||
*/
|
||
@Deprecated
|
||
default String authorize() {
|
||
throw new AuthException(AuthResponseStatus.NOT_IMPLEMENTED);
|
||
}
|
||
|
||
/**
|
||
* 返回带{@code state}参数的认证url,授权回调时会带上这个{@code state}
|
||
*
|
||
* @param state state 验证授权流程的参数,可以防止csrf
|
||
* @return 返回授权地址
|
||
*/
|
||
default String authorize(String state) {
|
||
throw new AuthException(AuthResponseStatus.NOT_IMPLEMENTED);
|
||
}
|
||
|
||
/**
|
||
* 第三方登录
|
||
*
|
||
* @param authCallback 用于接收回调参数的实体
|
||
* @return 返回登录成功后的用户信息
|
||
*/
|
||
default AuthResponse login(AuthCallback authCallback) {
|
||
throw new AuthException(AuthResponseStatus.NOT_IMPLEMENTED);
|
||
}
|
||
|
||
/**
|
||
* 撤销授权
|
||
*
|
||
* @param authToken 登录成功后返回的Token信息
|
||
* @return AuthResponse
|
||
*/
|
||
default AuthResponse revoke(AuthToken authToken) {
|
||
throw new AuthException(AuthResponseStatus.NOT_IMPLEMENTED);
|
||
}
|
||
|
||
/**
|
||
* 刷新access token (续期)
|
||
*
|
||
* @param authToken 登录成功后返回的Token信息
|
||
* @return AuthResponse
|
||
*/
|
||
default AuthResponse refresh(AuthToken authToken) {
|
||
throw new AuthException(AuthResponseStatus.NOT_IMPLEMENTED);
|
||
}
|
||
}
|