<HTML xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><HEAD><meta http-equiv=Content-Type content="text/html; charset=utf-8" /><meta name=Generator content="Microsoft Word 12 (filtered medium)" /><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></HEAD>
<BODY lang=EN-AU link=blue vlink=purple>
<P><BR /><div class=WordSection1><p class=MsoNormal>Hi All,<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>I've figured it out, I had been using the RT::User object class where I should have been using RT::CurrentUser. A little more thought about what I was implementing also alerted me to the fact that what I am building is a possible security hole.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>I'll repeat that in case anyone has found this on google and plans to use it:<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>THIS CODE IS A POSSIBLE SECURITY FLAW! THINK LONG AND HARD!<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Anyhoo, I'm fairly sure I understand and have addressed the security issues here, so here's how I sorted this out for myself:<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal> In .../share/html/REST/1.0/search/ticket, changed the first few lines as such:<o:p></o:p></p><p class=MsoNormal><%ARGS><o:p></o:p></p><p class=MsoNormal>$restrictUser => undef<o:p></o:p></p><p class=MsoNormal>$query<o:p></o:p></p><p class=MsoNormal>$format => undef<o:p></o:p></p><p class=MsoNormal>$orderby => undef<o:p></o:p></p><p class=MsoNormal>$fields => undef<o:p></o:p></p><p class=MsoNormal></%ARGS><o:p></o:p></p><p class=MsoNormal><%INIT><o:p></o:p></p><p class=MsoNormal>use RT::Interface::REST;<o:p></o:p></p><p class=MsoNormal>my $output = "";<o:p></o:p></p><p class=MsoNormal>my $status = "200 Ok";<o:p></o:p></p><p class=MsoNormal>my $user = new RT::User;<o:p></o:p></p><p class=MsoNormal>my $current_user_obj = $session{CurrentUser};<o:p></o:p></p><p class=MsoNormal>if (lc $current_user_obj->UserObj->Name eq "restuser")<o:p></o:p></p><p class=MsoNormal>{<o:p></o:p></p><p class=MsoNormal>        $user->Load($restrictUser) if ( defined $restrictUser );<o:p></o:p></p><p class=MsoNormal>}<o:p></o:p></p><p class=MsoNormal>$user = $session{CurrentUser} unless ( $user->Id );<o:p></o:p></p><p class=MsoNormal>my $current_user = RT::CurrentUser->new( $user );<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>my $tickets = RT::Tickets->new($current_user);<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal># Parse and validate any field specifications.<o:p></o:p></p><p class=MsoNormal>...(the rest of the file)<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Now, just to point out and make absolutely clear, the possible security flaw here is that a user can view tickets they do not have the right to see. In this case I have circumvented this by only making use of $restrictUser when the logged in user is RestUser. As I am the only one who knows the password for restUser this functionality will only be accessible in scripts that I have created and setup to use RestUser.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>I'd very much appreciate, if anyone can see any further security holes or other bugs with what I've done, if you'd let me know.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><b><span style='font-family:"Arial","sans-serif"'>Regards<o:p></o:p></span></b></p><p class=MsoNormal><o:p> </o:p></p></div> 
<BR />
<TABLE style="WIDTH: 473px; HEIGHT: 165px" border=0 cellSpacing=0 cellPadding=0 width=473>
  <TBODY>
  <TR>
    <TD style="HEIGHT: 50px" colSpan=3><SPAN style="LINE-HEIGHT: 16px; FONT-FAMILY: Arial, Helvetica, sans-serif; FONT-SIZE: 12px"><span style='font-family:Arial; font-size:11pt; font-weight: bold; '>Chris</span> <span style='font-family:Arial; font-size:11pt; font-weight: bold; '>O'Kelly</span><BR /><SPAN style="FONT-SIZE: 14px"><B><span style='font-family:Arial; font-size:9pt; font-weight: normal; '>Web Administrator</span></B></SPAN><BR /></SPAN></TD></TR>
  <TR>
    <TD style="WIDTH: 178px" height=112 vAlign=top width=199 align=left><SPAN style="LINE-HEIGHT: 16px; FONT-FAMILY: Arial, Helvetica, sans-serif; FONT-SIZE: 12px"><table class=7f172dc6-f7d4-483a-a4cd-5841754651fbTable><tr><td><span style='font-family:Arial; font-size:x-small; color: #000000; font-weight: bold; '>Minecorp Australia</span></td></tr><tr><td><span style='font-family:arial; font-size:9pt; '>37 Murdoch Circuit</span></td></tr><tr><td><span style='font-family:arial; font-size:9pt; '>Acacia Ridge QLD 4110</span></td></tr><tr><td><span style='font-family:Arial; font-size:9pt; color: #0070C0; '><span style='font-family:arial; font-size:9pt; color: #0070C0; font-weight: bold; '><span style='font-family:arial; font-size:9pt; color: #0070C0; font-weight: bold; '><a href='http://www.minecorp.com.au' title='Minecorp Vehicle Solutions' target=''><span style='font-family:arial; font-size:9pt; color: #0070C0; font-weight: bold; '>minecorp.com.au</span></a></span></span></span></td></tr></table><BR /></SPAN></TD>
    <TD style="WIDTH: 290px" height=112 vAlign=top width=250 align=left><SPAN style="LINE-HEIGHT: 16px; FONT-FAMILY: Arial, Helvetica, sans-serif; FONT-SIZE: 12px"><B><table class=7f172dc6-f7d4-483a-a4cd-5841754651fbTable><tr><td width=600px><span style='font-family:Arial; font-size:9pt; font-weight: bold; '>P:   07 3723 1000</span></td></tr><tr><td width=600px><span style='font-family:Arial; font-size:9pt; font-weight: bold; '>M:  0450 586 190</span></td></tr><tr><td width=600px><span style='font-family:arial; font-size:9pt; font-weight: bold; '>E:  <a href='mailto:Chris.okelly@minecorp.com.au' title='Click to send email to Chris O'Kelly' target=''>Chris.okelly@minecorp.com.au</a></span></td></tr><tr><td width=600px><span style='font-family:Arial; font-size:9pt; color: #4F81BD; font-weight: bold; '>S:  <a href='http://skype.com' title='' target=''>chris.okelly.mvs</a></span></td></tr></table><BR /></B></SPAN></TD></TR></TBODY></TABLE> <IMG id=IMG1 border=0 src="http://oi46.tinypic.com/mw8nbd.jpg" width=430 height=132 /><BR /><BR /> 
</P></BODY></HTML>