Merge pull request #31 from xkcoding/refactor-1.9.3

调整部分代码
This commit is contained in:
yadong.zhang 2019-07-30 21:15:50 +08:00 committed by GitHub
commit f71fce6858
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View File

@ -72,6 +72,7 @@ public abstract class AuthDefaultRequest implements AuthRequest {
throw new AuthException(AuthResponseStatus.ILLEGAL_REQUEST);
}
AuthChecker.checkCode(source == AuthSource.ALIPAY ? authCallback.getAuth_code() : authCallback.getCode());
AuthChecker.checkState(authCallback);
AuthToken authToken = this.getAccessToken(authCallback);
AuthUser user = this.getUserInfo(authToken);

View File

@ -3,7 +3,8 @@ package me.zhyd.oauth.utils;
import me.zhyd.oauth.config.AuthConfig;
import me.zhyd.oauth.config.AuthSource;
import me.zhyd.oauth.exception.AuthException;
import me.zhyd.oauth.enums.AuthResponseStatus;
import me.zhyd.oauth.model.AuthCallback;
import me.zhyd.oauth.model.AuthResponseStatus;
/**
* 授权配置类的校验器
@ -65,4 +66,15 @@ public class AuthChecker {
throw new AuthException(AuthResponseStatus.ILLEGAL_CODE);
}
}
/**
* 校验回调传回的state
*
* @param authCallback 回调
*/
public static void checkState(AuthCallback authCallback) {
if (!authCallback.checkState()) {
throw new AuthException(AuthResponseStatus.ILLEGAL_REQUEST);
}
}
}