-
-
Save jerome-labidurie/d92d9441c4d021f5181d to your computer and use it in GitHub Desktop.
<html> | |
<head> | |
<!-- include Synology SSO js --> | |
<script src="http://ds:5000/webman/sso/synoSSO-1.0.0.js"></script> | |
</head> | |
<body> | |
<script> | |
/** Display login/logout button. | |
* Use a html element with id button | |
* @param logged boolean, are we logged ? | |
*/ | |
function setButton (logged) { | |
if (logged) { | |
document.getElementById('button').innerHTML = '<button onclick="SYNOSSO.logout()">Logout</button>'; | |
} else { | |
document.getElementById('button').innerHTML = '<button onclick="SYNOSSO.login()">Login</button>'; | |
} | |
} | |
/** Callback for SSO. | |
* Called by init() and login() | |
* @param reponse the JSON returned by SSO. See Syno SSO Dev Guide. | |
*/ | |
function authCallback(reponse) { | |
console.log(JSON.stringify(reponse)); | |
if (reponse.status == 'login') { | |
console.log('logged'); | |
setButton(true); | |
} | |
else { | |
console.log('not logged ' + reponse.status); | |
setButton(false); | |
} | |
} | |
SYNOSSO.init({ | |
oauthserver_url: 'http://ds:5000', | |
app_id: 'a80a2d975796104eb7a7f38b971a8f99', | |
redirect_uri: 'http://ds/test/relay.html', //no idea what this is :) | |
callback: authCallback | |
}); | |
</script> | |
<h1> Syno SSO test</h1> | |
<p id='button'></p> | |
</body> | |
</html> |
@LucasHerb
No matter how much I tried, I could not get this script to work in 2020, apparently due to updates in the Chrome security policy. I wrote my version in php, maybe it will help you – https://github.com/dagababaev/Synology_SSO_integration
@dagababaev Are you able to logout from the php version? I saw that the variables get unset, however, as I refresh the page, the auth gets passed and the variables get set again.
Also, the javascript version does not seem to work for me.
@sandrickn
it's true If you stay signed in Synology. To log out you must send command to Synology (i am not use it), but not only your web site
Hi all,
I'm using the code from dagababaev . On my WordPress-site. I'm able to login, from the WordPress-site, using "Synology SSL Server", and with a DSM-user. All works fine. But at the end I'm not able to show the logged-in user the home-page of the WordPress-site. Most probably because I have (almost) no knowledge of php.
Anybody any idea ?
Hello! The example is great, but after logout and try to login again the form window only blinks and the status is "not_login". I try incognito mode and clear cookies with no effect. Is this a bug in Synology SSO or after logout should be any other sequence to clean something?