sso.html 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  5. <meta charset="UTF-8">
  6. <title></title>
  7. <script src="../o2_core/o2.min.js"></script>
  8. <script src="js/sso.min.js"></script>
  9. <script>
  10. o2.addReady(function(){
  11. o2.JSON.get("res/config/config.json", function(config){
  12. if (config.proxyCenterEnable){
  13. if (o2.typeOf(config.center)==="array"){
  14. config.center.forEach(function(c){
  15. c.port = window.location.port || 80;
  16. })
  17. }else{
  18. config.port = window.location.port || 80;
  19. }
  20. }
  21. if (!window.layout) window.layout = {};
  22. window.layout.config = config;
  23. getServiceAddress(config, function(address){
  24. var locate = window.location;
  25. var protocol = locate.protocol;
  26. var addressObj = layout.serviceAddressList["x_organization_assemble_authentication"];
  27. var defaultPort = layout.config.app_protocol==='https' ? "443" : "80";
  28. var appPort = addressObj.port || window.location.port;
  29. var address = protocol+"//"+(addressObj.host || window.location.hostname)+((!appPort || appPort.toString()===defaultPort) ? "" : ":"+appPort)+addressObj.context;
  30. var uri = new URI(window.location.toString());
  31. var xtoken = uri.getData("xtoken");
  32. var client = uri.getData("client");
  33. var redirect = uri.getData("redirect");
  34. if (xtoken){
  35. var res = new Request.JSON({
  36. //url: "http://hbxa01.bf.ctc.com:20080/x_organization_assemble_authentication/jaxrs/sso",
  37. url: o2.filterUrl(address+"/jaxrs/sso"),
  38. secure: false,
  39. method: "POST",
  40. noCache: true,
  41. withCredentials: true,
  42. onSuccess: function(responseJSON, responseText){
  43. if (redirect){
  44. window.location = redirect;
  45. }else{
  46. window.location = "/";
  47. }
  48. }.bind(this),
  49. onFailure: function(xhr){
  50. window.location = "/";
  51. }.bind(this),
  52. onError: function(text, error){
  53. window.location = "/";
  54. }.bind(this)
  55. });
  56. res.setHeader("Content-Type", "application/json; charset=utf-8");
  57. var json = {"token": encodeURIComponent(xtoken), "client": client};
  58. res.send(JSON.encode(json));
  59. }else{
  60. if (redirect){
  61. window.location = redirect;
  62. }else{
  63. window.location = "/";
  64. }
  65. }
  66. });
  67. });
  68. });
  69. </script>
  70. </head>
  71. <body bgcolor="#faebd7" bgcolor="#ffc0cb">
  72. </body>
  73. </html>