feat: oidc-demo 适配 Spring Authorization Server

This commit is contained in:
zlt2000
2024-03-05 17:51:37 +08:00
parent 9dc20d56c9
commit fdb97c4c3a
3 changed files with 3 additions and 23 deletions
@@ -10,16 +10,6 @@
<body>
<script>
window.onload = function() {
//url获取state
let state = getQueryVariable('state');
let localState = sessionStorage.getItem("state");
//判断state防止CSRF攻击
if (localState !== state) {
alert('state参数无效!');
let state = getState();
sessionStorage.setItem("state", state);
window.location = getAuthorizeUri(state);
}
//url获取code
let code = getQueryVariable('code');
@@ -16,10 +16,8 @@
</div>
<script>
function login() {
let state = getState();
sessionStorage.setItem("visitUri", window.location.href);
sessionStorage.setItem("state", state);
window.location = getAuthorizeUri(state);
window.location = getAuthorizeUri();
}
window.onload = function() {
@@ -6,22 +6,14 @@ let uaaUri = 'http://127.0.0.1:9900/api-uaa/oauth/';
//端口
let port = 8082;
function getAuthorizeUri(state) {
return uaaUri+'authorize?client_id='+clientId+'&redirect_uri=http://127.0.0.1:'+port+'/callback.html&scope=openid&response_type=code&state='+state;
function getAuthorizeUri() {
return uaaUri+'authorize?client_id='+clientId+'&redirect_uri=http://127.0.0.1:'+port+'/callback.html&scope=openid&response_type=code';
}
function getLogoutUri(accessToken) {
return uaaUri+'remove/token?redirect_uri=http://127.0.0.1:'+port+'/index.html&access_token='+accessToken;
}
function getState() {
let state='';
for (let i = 0; i < 6; i++) {
state += FULL_CHARTER[Math.floor(Math.random() * 52)];
}
return state;
}
/**
* 获取url参数
*/