Skip to content

Instantly share code, notes, and snippets.

@explon
Created September 23, 2015 06:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save explon/88b2e34c93b09b7f2daa to your computer and use it in GitHub Desktop.
Save explon/88b2e34c93b09b7f2daa to your computer and use it in GitHub Desktop.
SSO 前端例子
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>SSO Demo</title>
<script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
</head>
<body>
<!-- Passport 登录成功后的处理页面 -->
<script type="text/javascript">
var PASSPORT_TOKEN = '[加密后的令牌, 由服务端输出]';
$(document).ready(function () {
$.getJSON('http://a.com/sso.php?token=' + PASSPORT_TOKEN + '&jsoncallback=?', function (result) {
if (result.state == 'success')
{
// SSO 应用登录成功处理
}
else if (result.state == 'error')
{
// SSO 应用登录失败处理
}
});
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment