<?php
/*
* OIDplus 2.0
* Copyright 2019 Daniel Marschall, ViaThinkSoft
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class OIDplusAuthUtils {
// RA authentification functions
public static function raLogin($email) {
if (strpos($email, '|') !== false) return;
$ses = new OIDplusSessionHandler(OIDPLUS_SESSION_SECRET);
$list = $ses->getValue('oidplus_logged_in');
if (!in_array($email, $ary)) $ary[] = $email;
$ses->setValue('oidplus_logged_in', $list);
}
public static function raLogout($email) {
$ses = new OIDplusSessionHandler(OIDPLUS_SESSION_SECRET);
$list = $ses->getValue('oidplus_logged_in');
if ($key !== false) unset($ary[$key]);
$ses->setValue('oidplus_logged_in', $list);
}
public static function raLogoutAll() {
$ses = new OIDplusSessionHandler(OIDPLUS_SESSION_SECRET);
$ses->setValue('oidplus_logged_in', '');
}
public static function loggedInRaList() {
$ses = new OIDplusSessionHandler(OIDPLUS_SESSION_SECRET);
$list = $ses->getValue('oidplus_logged_in');
}
public static function isRaLoggedIn($email) {
return in_array($email, self::loggedInRaList());
}
// Admin authentification functions
public static function adminLogin() {
$ses = new OIDplusSessionHandler(OIDPLUS_SESSION_SECRET);
$ses->setValue('oidplus_admin_logged_in', '1');
}
public static function adminLogout() {
$ses = new OIDplusSessionHandler(OIDPLUS_SESSION_SECRET);
$ses->setValue('oidplus_admin_logged_in', '');
}
public static function adminCheckPassword($password) {
}
public static function isAdminLoggedIn() {
$ses = new OIDplusSessionHandler(OIDPLUS_SESSION_SECRET);
return $ses->getValue('oidplus_admin_logged_in') == '1';
}
// Action.php auth arguments
public static function makeAuthKey($data) {
return $calc_authkey;
}
public static function validateAuthKey($data, $auth_key) {
return self::makeAuthKey($data) == $auth_key;
}
}