CSP Gateway Configuration Guide - InterSystems Documentation
CSP Gateway Configuration Guide - InterSystems Documentation
CSP Gateway Configuration Guide - InterSystems Documentation
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Implementing HTTP authentication for <strong>CSP</strong> applications<br />
Set %session.Preserve = 0<br />
Quit 1<br />
}<br />
ClassMethod OnPage() As %Status<br />
{<br />
Set crlf=$Char(13,10)<br />
Set type=%request.GetCgiEnv("AUTH_TYPE", "")<br />
Set user=%request.GetCgiEnv("REMOTE_USER", "")<br />
Set pwd=%request.GetCgiEnv("AUTH_PASSWORD", "")<br />
Set auth=0 If $ZConvert(type,"L")'="basic" Set auth=1<br />
If auth=0,user'="",$Get(^%Users(user))=pwd Set auth=1<br />
If auth=1 {<br />
Write "HTTP/1.1 200 OK"_crlf<br />
Write "Content-Type: text/html"_crlf<br />
Write "Content-Length: 0"_crlf<br />
Write "Connection: close"_crlf_crlf<br />
}<br />
Else {<br />
Write "HTTP/1.1 401 Authorization Required"_crlf<br />
Write "WWW-Authenticate: Basic realm=""<strong>CSP</strong> samples"""_crlf<br />
Write "Content-Type: text/html"_crlf<br />
Write "Content-Length: 0"_crlf<br />
Write "Connection: close"_crlf_crlf<br />
}<br />
Quit $$$OK<br />
}<br />
ClassMethod OnHTTPHeader(ByRef OutputBody As %Boolean) As %Status<br />
{<br />
Quit $$$OK<br />
}<br />
For methods (1) and (3) a custom error page can be specified for login failure by using the Apache ErrorDocument<br />
directive. For example:<br />
ErrorDocument /error/my_authentication_error.html<br />
Of course, for method (2) the text of the error message is controlled by the <strong>CSP</strong> application.<br />
<strong>CSP</strong> <strong>Gateway</strong> <strong>Configuration</strong> <strong>Guide</strong> 49