A simple html page to help your application use USTC CAS(Central Authentication Service, https://passport.ustc.edu.cn/).
- A static html page under
*.ustc.edu.cn
(eg.home.ustc.edu.cn
). - An API from your application to receive and use the CAS ticket.
- Edit
index.html
// This page's url, the host must end with ".ustc.edu.cn"
var serviceURL = "https://home.ustc.edu.cn/~your_name/cas/index.html?id={0}";
// When this page get ticket, user will be redirected to apiUrl
var apiURL = "http://your_api_host/cas?id={0}&ticket={1}&service={2}";
- Upload
index.html
to your directory (Make sureindex.html
is atserviceURL
)
- Put the
serviceURL
in your application(with a specificid
, which can help you controll the redirect when he come back from CAS server) - When a user click the link, he will be first redirected to
CASURL
to login. - If the user logins successfully, he will be redirected again to
serviceURL
, and automatically redirected to yourapiURL
with parameterid
,ticket
andservice
. - With the
ticket
andservice
, your api server can get the login user from CAS server.(eg. get the content fromhttps://passport.ustc.edu.cn/serviceValidate?ticket=%s&service=%s
)
- The parameter
id
isn't reliable. It's just for controlling the redirect more simply. Don't trust it. - The common way to identify user is to use COOKIES or SESSIONS.
More info: https://en.wikipedia.org/wiki/Central_Authentication_Service