Merge pull request 'Return to the selected public intake after Support SSO renewal (328)' (#42) from dev/MC:dev/ticket-328-support-polish into checkpoint/alpha-1.0.0.3
Reviewed-on: unimatrix/MC#42
This commit is contained in:
commit
87a131b397
5 changed files with 71 additions and 3 deletions
|
|
@ -6,6 +6,8 @@ This package implements consolidated sources 119, 133 and 134. It changes presen
|
|||
|
||||
The homepage resolves an explicit list through `Topic::getPublicHelpTopics()`. It presents parental requests (with the separate child-removal link), GDPR removal, general help, Sales, forum help, technical problems, access issues, ban appeals and Alpha signup. Missing/non-public topics produce no card. Existing priority relationships and specialised appeal/Alpha handlers remain intact. Cards use two equal desktop columns and one mobile column; the final card has the same treatment as every other card.
|
||||
|
||||
Native parent-prefixed topic labels are matched by their unique leaf name; ambiguous public branches are omitted. A public intake selected before sign-in is remembered for five minutes and consumed once after successful existing SSO/native authentication. Only relative `/open.php`, a currently public positive topic ID, or `/alpha-signup.php` is accepted. Recheck topic visibility after sign-in. Staff/Dev/appeal flows retain precedence; external URLs, private topics and POST payloads are excluded. The common SSO nonce validation and account/native authorisation checks are unchanged.
|
||||
|
||||
`configure-public-sales.php` defaults to a read-only plan. Run it with `--apply` only for an authorised rollout. It creates **Customer sales enquiries**, routed through the existing Sales department/team, using only standard Ticket Details form 2. The existing private **Sales enquiries** email/internal topic remains private and unchanged. The installer requires transactional topic tables, serialises creation with a named lock, validates repeat runs and refuses routing/form drift. It does not create a ticket or process a payment/refund.
|
||||
|
||||
## Shared actions
|
||||
|
|
|
|||
|
|
@ -4,11 +4,12 @@ require_once '/home/dunerealms/apps/integrations/shared-header.php';
|
|||
require_once INCLUDE_DIR.'class.auth.php';
|
||||
require_once '/home/dunerealms/apps/integrations/bridge.php';
|
||||
require_once '/home/dunerealms/apps/integrations/osticket/staff-scope.php';
|
||||
require_once '/home/dunerealms/apps/integrations/osticket/intake-navigation.php';
|
||||
function dune_ticket_identity(){return dune_bridge('identity',['sessionRef'=>$_SESSION['dune_session_ref']??'']);}
|
||||
class DuneClientAuthentication extends ExternalUserAuthenticationBackend {
|
||||
static $id='dunerealms-client';static $name='DuneRealms';static $service_name='DuneRealms';
|
||||
function authenticate($username,$password){return false;}
|
||||
function triggerAuth(){header('Location: /dune-sso.php');exit;}
|
||||
function triggerAuth(){$next=dune_requested_intake_path(basename($_SERVER['SCRIPT_NAME']??''),$_GET,$_SERVER['REQUEST_METHOD']??'GET');header('Location: /dune-sso.php'.($next!==null?'?intake='.rawurlencode($next):''));exit;}
|
||||
function signOn(){
|
||||
$identity=dune_ticket_identity();if(!$identity)return null;
|
||||
$email=$identity['id'].'@accounts.dunerealms.invalid';
|
||||
|
|
@ -43,7 +44,7 @@ class DuneAccountsPlugin extends Plugin {
|
|||
if(in_array($file,['dune-sso.php','cron.php','api.php'],true))return;
|
||||
if(strtolower($_SERVER['HTTP_X_REQUESTED_WITH']??'')!=='xmlhttprequest')ob_start('dune_shared_header');
|
||||
$identity=dune_ticket_identity();
|
||||
if(!is_array($identity)||!is_array($identity['permissions']??null)){if(in_array($file,['index.php','service-targets.php'],true)&&!str_contains($_SERVER['SCRIPT_NAME']??'','/scp/'))return;if(strtolower($_SERVER['HTTP_X_REQUESTED_WITH']??'')==='xmlhttprequest'){http_response_code(401);exit('Sign in again to continue.');}$target='/dune-sso.php';if($file==='dev-tasks.php')$target.='?dev=1';if(str_contains($_SERVER['SCRIPT_NAME']??'','/scp/'))$target.='?staff=1';elseif($file==='appeal.php')$target.='?appeal='.rawurlencode($_GET['banId']??'');header('Location: '.$target);exit;}
|
||||
if(!is_array($identity)||!is_array($identity['permissions']??null)){if(in_array($file,['index.php','service-targets.php'],true)&&!str_contains($_SERVER['SCRIPT_NAME']??'','/scp/'))return;if(strtolower($_SERVER['HTTP_X_REQUESTED_WITH']??'')==='xmlhttprequest'){http_response_code(401);exit('Sign in again to continue.');}$target='/dune-sso.php';if($file==='dev-tasks.php')$target.='?dev=1';if(str_contains($_SERVER['SCRIPT_NAME']??'','/scp/'))$target.='?staff=1';elseif($file==='appeal.php')$target.='?appeal='.rawurlencode($_GET['banId']??'');elseif($next=dune_requested_intake_path($file,$_GET,$_SERVER['REQUEST_METHOD']??'GET'))$target.='?intake='.rawurlencode($next);header('Location: '.$target);exit;}
|
||||
if($file==='login.php'&&str_contains($_SERVER['SCRIPT_NAME']??'','/scp/')&&($_SERVER['REQUEST_METHOD']??'')==='GET'){
|
||||
if(!in_array('web.tickets.staff',$identity['permissions'],true)){http_response_code(403);exit('Staff ticket permission required.');}
|
||||
$now=time();if($now-(int)($_SESSION['dune_staff_renew_attempt']??0)<5){http_response_code(503);exit('Support sign-in could not be renewed. Return to the Account centre and retry the staff ticket desk.');}
|
||||
|
|
|
|||
|
|
@ -1,13 +1,23 @@
|
|||
<?php
|
||||
require '/home/dunerealms/apps/integrations/bridge.php';
|
||||
require __DIR__.'/main.inc.php';
|
||||
if(!isset($_GET['code'])){$_SESSION['dune_support_admin_requested']=($_GET['admin']??'')==='1';if(($_GET['dev']??'')==='1')$_SESSION['dune_dev_requested']=true;$_SESSION['dune_staff_requested']=($_GET['staff']??'')==='1';if(array_key_exists('appeal',$_GET))$_SESSION['dune_appeal_requested']=preg_match('/^[a-f0-9-]{36}$/i',$_GET['appeal'])?$_GET['appeal']:'';dune_begin_sso('osticket');}
|
||||
require_once __DIR__.'/intake-navigation.php';
|
||||
if(!isset($_GET['code'])){
|
||||
$_SESSION['dune_support_admin_requested']=($_GET['admin']??'')==='1';
|
||||
$_SESSION['dune_dev_requested']=($_GET['dev']??'')==='1';
|
||||
$_SESSION['dune_staff_requested']=($_GET['staff']??'')==='1';
|
||||
unset($_SESSION['dune_appeal_requested']);
|
||||
if(array_key_exists('appeal',$_GET))$_SESSION['dune_appeal_requested']=is_string($_GET['appeal'])&&preg_match('/^[a-f0-9-]{36}$/i',$_GET['appeal'])?$_GET['appeal']:'';
|
||||
dune_remember_intake_path($_SESSION,$_GET,time(),$_SERVER['REQUEST_METHOD']??'GET');
|
||||
dune_begin_sso('osticket');
|
||||
}
|
||||
$identity=dune_finish_sso('osticket');
|
||||
// A newly verified central sign-in must issue fresh native idle-time tokens.
|
||||
unset($_SESSION[':token']['client'],$_SESSION['TTD']);
|
||||
if(!empty($_SESSION['dune_staff_requested']))unset($_SESSION[':token']['staff']);
|
||||
$backend=UserAuthenticationBackend::getBackend('dunerealms-client');
|
||||
if(!$backend||!($user=$backend->signOn())||!$backend->login($user,$backend)){http_response_code(503);exit('Support sign-in unavailable. Contact the operator.');}
|
||||
$intakeReturn=dune_take_intake_path($_SESSION,time());
|
||||
if(!empty($_SESSION['dune_staff_requested'])&&in_array('web.tickets.staff',$identity['permissions'],true)){
|
||||
if(!empty($_SESSION['dune_support_admin_requested'])&&!in_array('web.tickets.admin',$identity['permissions'],true)){unset($_SESSION['dune_support_admin_requested']);http_response_code(403);exit('Support administration permission required.');}
|
||||
unset($_SESSION['dune_staff_requested']);$name=str_replace('-','',$identity['id']);
|
||||
|
|
@ -28,4 +38,5 @@ if(!empty($_SESSION['dune_staff_requested'])&&in_array('web.tickets.staff',$iden
|
|||
}
|
||||
if(isset($_SESSION['dune_appeal_requested'])){$id=$_SESSION['dune_appeal_requested'];unset($_SESSION['dune_appeal_requested']);header('Location: /appeal.php?banId='.rawurlencode($id));exit;}
|
||||
if(!empty($_SESSION['dune_dev_requested'])){unset($_SESSION['dune_dev_requested']);header('Location: /dev-tasks.php');exit;}
|
||||
if($intakeReturn!==null){header('Location: '.$intakeReturn,true,303);exit;}
|
||||
header('Location: /tickets.php');exit;
|
||||
|
|
|
|||
31
website/integrations/osticket/intake-navigation.php
Normal file
31
website/integrations/osticket/intake-navigation.php
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
// Navigation only. Existing SSO nonce, identity and native form authorisation remain authoritative.
|
||||
function dune_public_intake_path($candidate) {
|
||||
if (!is_string($candidate) || strlen($candidate)>128) return null;
|
||||
if ($candidate==='/alpha-signup.php' || $candidate==='/open.php') return $candidate;
|
||||
if (!preg_match('~^/open\.php\?topicId=([1-9][0-9]{0,8})$~D',$candidate,$match)) return null;
|
||||
$public=Topic::getPublicHelpTopics();
|
||||
return is_array($public) && array_key_exists((int)$match[1],$public) ? $candidate : null;
|
||||
}
|
||||
function dune_requested_intake_path($file, $query, $method) {
|
||||
if (!in_array($method,['GET','HEAD'],true)) return null;
|
||||
if ($file==='alpha-signup.php') return '/alpha-signup.php';
|
||||
if ($file!=='open.php') return null;
|
||||
if (!array_key_exists('topicId',$query)) return '/open.php';
|
||||
if (!is_string($query['topicId'])) return null;
|
||||
return dune_public_intake_path('/open.php?topicId='.$query['topicId']);
|
||||
}
|
||||
function dune_remember_intake_path(&$session, $query, $now, $method='GET') {
|
||||
unset($session['dune_intake_return']);
|
||||
if (!in_array($method,['GET','HEAD'],true)) return;
|
||||
// Explicit staff, Dev and appeal flows retain their existing destinations.
|
||||
if (($query['staff']??'')==='1' || ($query['admin']??'')==='1' || ($query['dev']??'')==='1' || array_key_exists('appeal',$query)) return;
|
||||
$path=dune_public_intake_path($query['intake']??null);
|
||||
if ($path!==null) $session['dune_intake_return']=['path'=>$path,'expires'=>$now+300];
|
||||
}
|
||||
function dune_take_intake_path(&$session, $now) {
|
||||
$saved=$session['dune_intake_return']??null;unset($session['dune_intake_return']);
|
||||
if (!is_array($saved) || !is_int($saved['expires']??null) || $saved['expires']<=$now || $saved['expires']>$now+300) return null;
|
||||
// Recheck the current catalogue: a topic may have become private during sign-in.
|
||||
return dune_public_intake_path($saved['path']??null);
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
class Topic {static $public=[1=>'General support',11=>'Report a Problem / Access Issue',14=>'Parental consent request [Preview]',21=>'Customer sales enquiries'];static function getPublicHelpTopics(){return self::$public;}}
|
||||
require dirname(__DIR__).'/intake-navigation.php';
|
||||
$checks=0;
|
||||
function intake_check($value,$label){global $checks;$checks++;if(!$value)throw new RuntimeException($label);}
|
||||
foreach(['/open.php','/alpha-signup.php','/open.php?topicId=21','/open.php?topicId=11','/open.php?topicId=14']as$path)intake_check(dune_public_intake_path($path)===$path,'Public intake rejected');
|
||||
foreach([null,[],false,'https://example.test/open.php','//example.test/open.php','/\\example.test','/../open.php','/%6fpen.php','/open.php#x',"/open.php\r\nLocation: https://example.test",'/open.php?topicId=17','/open.php?topicId=20','/open.php?topicId=0','/open.php?topicId=01','/open.php?topicId=-1','/open.php?topicId=999','/open.php?topicId=21&topicId=14','/open.php?topicId=21&next=https://example.test','/open.php?topicId[]=21','/open.php?topicId=999999999999999999','/scp/tickets.php','/dev-tasks.php','/tickets.php?id=1','/alpha-signup.php?anything=1']as$path)intake_check(dune_public_intake_path($path)===null,'Unsafe or private intake accepted');
|
||||
intake_check(dune_requested_intake_path('open.php',['topicId'=>'21'],'GET')==='/open.php?topicId=21','Selected public topic lost');
|
||||
intake_check(dune_requested_intake_path('open.php',[],'HEAD')==='/open.php','Generic intake lost');
|
||||
intake_check(dune_requested_intake_path('alpha-signup.php',[],'GET')==='/alpha-signup.php','Alpha route lost');
|
||||
foreach([['open.php',['topicId'=>['21']],'GET'],['open.php',['topicId'=>'17'],'GET'],['open.php',['topicId'=>'21'],'POST'],['tickets.php',[],'GET']]as$args)intake_check(dune_requested_intake_path(...$args)===null,'Invalid request remembered');
|
||||
$session=['dune_sso_state'=>'existing-nonce','dune_session_ref'=>'existing-reference'];
|
||||
dune_remember_intake_path($session,['intake'=>'/open.php?topicId=21'],100);
|
||||
intake_check(dune_take_intake_path($session,101)==='/open.php?topicId=21','Successful sign-in route lost');
|
||||
intake_check(dune_take_intake_path($session,102)===null,'Return context replayed');
|
||||
intake_check($session===['dune_sso_state'=>'existing-nonce','dune_session_ref'=>'existing-reference'],'Authentication state changed');
|
||||
foreach([['staff'=>'1'],['admin'=>'1'],['dev'=>'1'],['appeal'=>'']]as$special){dune_remember_intake_path($session,['intake'=>'/open.php?topicId=21'],100);dune_remember_intake_path($session,$special+['intake'=>'/open.php?topicId=21'],101);intake_check(dune_take_intake_path($session,102)===null,'Specialised flow overridden');}
|
||||
dune_remember_intake_path($session,['intake'=>'/open.php?topicId=21'],100,'POST');intake_check(dune_take_intake_path($session,101)===null,'POST context remembered');
|
||||
dune_remember_intake_path($session,['intake'=>'/open.php?topicId=21'],100);intake_check(dune_take_intake_path($session,400)===null,'Expired context accepted');
|
||||
dune_remember_intake_path($session,['intake'=>'/open.php?topicId=21'],100);intake_check(dune_take_intake_path($session,99)===null,'Future context accepted');
|
||||
dune_remember_intake_path($session,['intake'=>'/open.php?topicId=21'],100);unset(Topic::$public[21]);intake_check(dune_take_intake_path($session,101)===null,'Now-private topic accepted');
|
||||
Topic::$public=null;intake_check(dune_public_intake_path('/open.php?topicId=21')===null,'Unavailable catalogue accepted');
|
||||
echo "$checks public-intake navigation checks passed; nonce, identity, specialised flows and POST contents preserved.\n";
|
||||
Loading…
Reference in a new issue

Staff