The code is as follows, thanks in advance
I modified this Discourse sso provider login · GitHub
Link to the site using it and that has the issue in Firefox: https://vceliquidrecipes.com/
LOGIN FORM
<div class="row mt-1">
<div class="col-md-12 d-flex justify-content-center">
<p><a class="btn btn-success" href="'.$discourse_url.'/session/sso_provider?'.$query.'" role="button">Sign in</a> <a class="btn btn-success" href="https://vapingcommunity.co.uk/signup" role="button">Register</a></p>
</div>
</div>
$sso_secret = 'ITSASECRET';
$discourse_url = 'https://vapingcommunity.co.uk';
$nonce = hash('sha512', mt_rand());
$_SESSION['nonce'] = $nonce;
$payload = base64_encode( http_build_query( array (
'nonce' => $nonce,
'return_sso_url' => $me
)
) );
$request = array(
'sso' => $payload,
'sig' => hash_hmac('sha256', $payload, $sso_secret )
);
$query = http_build_query($request);
if(!empty($_GET) and isset($_GET['sso'])){
$sso_secret = 'ITSASECRET';
if(isset($_SESSION['loggedin']) && isset($_SESSION['username']) && $_SESSION['loggedin'] == true){
header("location: /");
die();
}
$sso = $_GET['sso'];
$sig = $_GET['sig'];
if(hash_hmac('sha256', urldecode($sso), $sso_secret) !== $sig){
header("HTTP/1.1 404 Not Found");
die();
}
In my controller
$sso = urldecode($sso);
$query = array();
parse_str(base64_decode($sso), $query);
$username = $query['username'];
$useremail = $query['email'];
if(!empty($query['avatar_url'])) {
$avatar_url = $query['avatar_url'];
}
else {
$avatar_url = $miscf->fullURL().'/images/defaultAvatar.png';
}
$userisadmin = $query['admin'];
$userismoderator = $query['moderator'];
$usergroup = $query['groups'];
$externalid = $query['external_id'];
if ($userf->checkUserEIDExists($externalid) == false) {
$userf->addUser($username,$useremail,$avatar_url,$userisadmin,$userismoderator,$usergroup,$externalid);
}
$nonce = $_SESSION['nonce'];
if($query['nonce'] != $nonce){
header("HTTP/1.1 404 Not Found");
die();
}
$userf->loginUser($query['username'],$query['external_id'],$avatar_url,$query['groups']);
Login function:
*SETS COOKIE DOES OTHER MISC STUFF LIKE USER CHECKS*
*FINISHES WITH THIS*
if(isset($_SESSION['url']))
$url = $_SESSION['url'];
else
$url = "";
$miscf = new miscf();
$fullurl = $miscf->fullURL().$url;
header("Location:".$fullurl);
unset($_SESSION['url']);
die();