/usr/share/doc/libapache2-mod-perl2-doc/docs/2.0/api/Apache2/Access.html is in libapache2-mod-perl2-doc 2.0.8+httpd24-r1449661-6ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 | <?xml version="1.0" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rev="made" href="mailto:root@localhost" />
</head>
<body style="background-color: white">
<ul id="index">
<li><a href="#NAME">NAME</a></li>
<li><a href="#Synopsis">Synopsis</a></li>
<li><a href="#Description">Description</a></li>
<li><a href="#API">API</a>
<ul>
<li><a href="#allow_methods">allow_methods</a></li>
<li><a href="#allow_options">allow_options</a></li>
<li><a href="#allow_overrides">allow_overrides</a></li>
<li><a href="#allow_override_opts">allow_override_opts</a></li>
<li><a href="#auth_name">auth_name</a></li>
<li><a href="#auth_type">auth_type</a></li>
<li><a href="#get_basic_auth_pw">get_basic_auth_pw</a></li>
<li><a href="#get_remote_logname">get_remote_logname</a></li>
<li><a href="#note_auth_failure">note_auth_failure</a></li>
<li><a href="#note_basic_auth_failure">note_basic_auth_failure</a></li>
<li><a href="#note_digest_auth_failure">note_digest_auth_failure</a></li>
<li><a href="#requires">requires</a></li>
<li><a href="#satisfies">satisfies</a></li>
<li><a href="#some_auth_required">some_auth_required</a></li>
</ul>
</li>
<li><a href="#See-Also">See Also</a></li>
<li><a href="#Copyright">Copyright</a></li>
<li><a href="#Authors">Authors</a></li>
</ul>
<h1 id="NAME">NAME</h1>
<p>Apache2::Access - A Perl API for Apache request object: Access, Authentication and Authorization.</p>
<h1 id="Synopsis">Synopsis</h1>
<pre><code> use Apache2::Access ();
# allow only GET method
$r->allow_methods(1, qw(GET));
# Apache Options value
$options = $r->allow_options();
# Apache AllowOverride value
$allow_override = $r->allow_overrides();
# which Options are allowed by AllowOverride (since Apache 2.2)
$allow_override_opts = $r->allow_override_opts();
# auth name ("foo bar")
$auth_name = $r->auth_name();
# auth type
$auth_type = $r->auth_type();
$r->auth_type("Digest");
# Basic authentication process
my ($rc, $passwd) = $r->get_basic_auth_pw();
# the login name of the remote user (RFC1413)
$remote_logname = $r->get_remote_logname();
# dynamically figure out which auth has failed
$r->note_auth_failure();
# note Basic auth failure
$r->note_basic_auth_failure();
# note Digest auth failure
$r->note_digest_auth_failure();
# Apache Request value(s)
$requires = $r->requires();
# Apache Satisfy value (as a number)
$satisfy = $r->satisfies();
# check whether some auth is configured
$need_auth = $r->some_auth_required();</code></pre>
<h1 id="Description">Description</h1>
<p>The API provided by this module deals with access, authentication and authorization phases.</p>
<p><code>Apache2::Access</code> extends <code><a>Apache2::RequestRec</a></code>.</p>
<h1 id="API">API</h1>
<p><code>Apache2::Access</code> provides the following functions and/or methods:</p>
<h2 id="allow_methods"><code>allow_methods</code></h2>
<p>Specify which HTTP methods are allowed</p>
<pre><code> $r->allow_methods($reset);
$r->allow_methods($reset, @methods);</code></pre>
<dl>
<dt id="obj:-r-Apache2::RequestRec-object">obj: <code>$r</code> ( <code><a>Apache2::RequestRec object</a></code> )</dt>
<dd>
<p>The current request</p>
</dd>
<dt id="arg1:-reset-boolean">arg1: <code>$reset</code> ( boolean )</dt>
<dd>
<p>If a true value is passed all the previously allowed methods are removed. Otherwise the list is left intact.</p>
</dd>
<dt id="opt-arg2:-methods-array-of-strings">opt arg2: <code>@methods</code> ( array of strings )</dt>
<dd>
<p>a list of HTTP methods to be allowed (e.g. <code>GET</code> and <code>POST</code>)</p>
</dd>
<dt id="ret:-no-return-value">ret: no return value</dt>
<dd>
</dd>
<dt id="since:-2.0.00">since: 2.0.00</dt>
<dd>
</dd>
</dl>
<p>For example: here is how to allow only <code>GET</code> and <code>POST</code> methods, regardless to what was the previous setting:</p>
<pre><code> $r->allow_methods(1, qw(GET POST));</code></pre>
<h2 id="allow_options"><code>allow_options</code></h2>
<p>Retrieve the value of <code>Options</code> for this request</p>
<pre><code> $options = $r->allow_options();</code></pre>
<dl>
<dt id="obj:-r-Apache2::RequestRec-object1">obj: <code>$r</code> ( <code><a>Apache2::RequestRec object</a></code> )</dt>
<dd>
<p>The current request</p>
</dd>
<dt id="ret:-options-integer">ret: <code>$options</code> ( integer )</dt>
<dd>
<p>the <code>Options</code> bitmask. Normally used with bitlogic operators against <code><a>Apache2::Const :options constants</a></code>.</p>
</dd>
<dt id="since:-2.0.001">since: 2.0.00</dt>
<dd>
</dd>
</dl>
<p>For example if the configuration for the current request was:</p>
<pre><code> Options None
Options Indexes FollowSymLinks</code></pre>
<p>The following applies:</p>
<pre><code> use Apache2::Const -compile => qw(:options);
$r->allow_options & Apache2::Const::OPT_INDEXES; # TRUE
$r->allow_options & Apache2::Const::OPT_SYM_LINKS; # TRUE
$r->allow_options & Apache2::Const::OPT_EXECCGI; # FALSE</code></pre>
<h2 id="allow_overrides"><code>allow_overrides</code></h2>
<p>Retrieve the value of <code>AllowOverride</code> for this request</p>
<pre><code> $allow_override = $r->allow_overrides();</code></pre>
<dl>
<dt id="obj:-r-Apache2::RequestRec-object2">obj: <code>$r</code> ( <code><a>Apache2::RequestRec object</a></code> )</dt>
<dd>
<p>The current request</p>
</dd>
<dt id="ret:-allow_override-integer">ret: <code>$allow_override</code> ( integer )</dt>
<dd>
<p>the <code>AllowOverride</code> bitmask. Normally used with bitlogic operators against <code><a>Apache2::Const :override constants</a></code>.</p>
</dd>
<dt id="since:-2.0.002">since: 2.0.00</dt>
<dd>
</dd>
</dl>
<p>For example if the configuration for the current request was:</p>
<pre><code> AllowOverride AuthConfig</code></pre>
<p>The following applies:</p>
<pre><code> use Apache2::Const -compile => qw(:override);
$r->allow_overrides & Apache2::Const::OR_AUTHCFG; # TRUE
$r->allow_overrides & Apache2::Const::OR_LIMIT; # FALSE</code></pre>
<h2 id="allow_override_opts"><code>allow_override_opts</code></h2>
<p>Retrieve the bitmask of allowed <code>Options</code> set by <code>AllowOverride Options=...</code> for this request</p>
<pre><code> $override_opts = $r->allow_override_opts();</code></pre>
<p>Enabling single options was introduced in Apache 2.2. For Apache 2.0 this function returns <code><a>Apache2::Const::OPT_UNSET</a></code> | <code><a>Apache2::Const::OPT_ALL</a></code> | <code><a>Apache2::Const::OPT_INCNOEXEC</a></code> | <code><a>Apache2::Const::OPT_SYM_OWNER</a></code> | <code><a>Apache2::Const::OPT_MULTI</a></code>, which corresponds to the default value (if not set) for Apache 2.2.</p>
<dl>
<dt id="obj:-r-Apache2::RequestRec-object3">obj: <code>$r</code> ( <code><a>Apache2::RequestRec object</a></code> )</dt>
<dd>
<p>The current request</p>
</dd>
<dt id="ret:-override_opts-integer">ret: <code>$override_opts</code> ( integer )</dt>
<dd>
<p>the override options bitmask. Normally used with bitlogic operators against <code><a>Apache2::Const :options constants</a></code>.</p>
</dd>
<dt id="since:-2.0.3">since: 2.0.3</dt>
<dd>
</dd>
</dl>
<p>For example if the configuration for the current request was:</p>
<pre><code> AllowOverride Options=Indexes,ExecCGI</code></pre>
<p>The following applies:</p>
<pre><code> use Apache2::Const -compile => qw(:options);
$r->allow_override_opts & Apache2::Const::OPT_EXECCGI; # TRUE
$r->allow_override_opts & Apache2::Const::OPT_SYM_LINKS; # FALSE</code></pre>
<h2 id="auth_name"><code>auth_name</code></h2>
<p>Get/set the current Authorization realm (the per directory configuration directive <code>AuthName</code>):</p>
<pre><code> $auth_name = $r->auth_name();
$auth_name = $r->auth_name($new_auth_name);</code></pre>
<dl>
<dt id="obj:-r-Apache2::RequestRec-object4">obj: <code>$r</code> ( <code><a>Apache2::RequestRec object</a></code> )</dt>
<dd>
<p>The current request</p>
</dd>
<dt id="opt-arg1:-new_auth_name-string">opt arg1: <code>$new_auth_name</code> ( string )</dt>
<dd>
<p>If <code>$new_auth_name</code> is passed a new <code>AuthName</code> value is set</p>
</dd>
<dt id="ret:-integer">ret: <code>$</code> ( integer )</dt>
<dd>
<p>The current value of <code>AuthName</code></p>
</dd>
<dt id="since:-2.0.003">since: 2.0.00</dt>
<dd>
</dd>
</dl>
<p>The <code>AuthName</code> directive creates protection realm within the server document space. To quote RFC 1945 "These realms allow the protected resources on a server to be partitioned into a set of protection spaces, each with its own authentication scheme and/or authorization database." The client uses the root URL of the server to determine which authentication credentials to send with each HTTP request. These credentials are tagged with the name of the authentication realm that created them. Then during the authentication stage the server uses the current authentication realm, from <code>$r->auth_name</code>, to determine which set of credentials to authenticate.</p>
<h2 id="auth_type"><code>auth_type</code></h2>
<p>Get/set the type of authorization required for this request (the per directory configuration directive <code>AuthType</code>):</p>
<pre><code> $auth_type = $r->auth_type();
$auth_type = $r->auth_type($new_auth_type);</code></pre>
<dl>
<dt id="obj:-r-Apache2::RequestRec-object5">obj: <code>$r</code> ( <code><a>Apache2::RequestRec object</a></code> )</dt>
<dd>
<p>The current request</p>
</dd>
<dt id="opt-arg1:-new_auth_type-string">opt arg1: <code>$new_auth_type</code> ( string )</dt>
<dd>
<p>If <code>$new_auth_type</code> is passed a new <code>AuthType</code> value is set</p>
</dd>
<dt id="ret:-integer1">ret: <code>$</code> ( integer )</dt>
<dd>
<p>The current value of <code>AuthType</code></p>
</dd>
<dt id="since:-2.0.004">since: 2.0.00</dt>
<dd>
</dd>
</dl>
<p>Normally <code>AuthType</code> would be set to <code>Basic</code> to use the basic authentication scheme defined in RFC 1945, <i>Hypertext Transfer Protocol -- HTTP/1.0</i>. However, you could set to something else and implement your own authentication scheme.</p>
<h2 id="get_basic_auth_pw"><code>get_basic_auth_pw</code></h2>
<p>Get the password from the request headers</p>
<pre><code> my ($rc, $passwd) = $r->get_basic_auth_pw();</code></pre>
<dl>
<dt id="obj:-r-Apache2::RequestRec-object6">obj: <code>$r</code> ( <code><a>Apache2::RequestRec object</a></code> )</dt>
<dd>
<p>The current request</p>
</dd>
<dt id="ret1:-rc-Apache2::Const-constant">ret1: <code>$rc</code> ( <code><a>Apache2::Const constant</a></code> )</dt>
<dd>
<p><code>Apache2::Const::OK</code> if the <code>$passwd</code> value is set (and assured a correct value in <code><a>$r->user</a></code>); otherwise it returns an error code, either <code>Apache2::Const::HTTP_INTERNAL_SERVER_ERROR</code> if things are really confused, <code>Apache2::Const::HTTP_UNAUTHORIZED</code> if no authentication at all seemed to be in use, or <code>Apache2::Const::DECLINED</code> if there was authentication, but it wasn't <code>Basic</code> (in which case, the caller should presumably decline as well).</p>
</dd>
<dt id="ret2:-ret-string">ret2: <code>$ret</code> (string)</dt>
<dd>
<p>The password as set in the headers (decoded)</p>
</dd>
<dt id="since:-2.0.005">since: 2.0.00</dt>
<dd>
</dd>
</dl>
<p>If <code><a href="#C_auth_type_">AuthType</a></code> is not set, this handler first sets it to <code>Basic</code>.</p>
<h2 id="get_remote_logname"><code>get_remote_logname</code></h2>
<p>Retrieve the login name of the remote user (RFC1413)</p>
<pre><code> $remote_logname = $r->get_remote_logname();</code></pre>
<dl>
<dt id="obj:-r-Apache2::RequestRec-object7">obj: <code>$r</code> ( <code><a>Apache2::RequestRec object</a></code> )</dt>
<dd>
<p>The current request</p>
</dd>
<dt id="ret:-remote_logname-string">ret: <code>$remote_logname</code> ( string )</dt>
<dd>
<p>The username of the user logged in to the client machine, or an empty string if it could not be determined via RFC1413, which involves querying the client's identd or auth daemon.</p>
</dd>
<dt id="since:-2.0.006">since: 2.0.00</dt>
<dd>
</dd>
</dl>
<p>Do not confuse this method with <code><a>$r->user</a></code>, which provides the username provided by the user during the server authentication.</p>
<h2 id="note_auth_failure"><code>note_auth_failure</code></h2>
<p>Setup the output headers so that the client knows how to authenticate itself the next time, if an authentication request failed. This function works for both basic and digest authentication</p>
<pre><code> $r->note_auth_failure();</code></pre>
<dl>
<dt id="obj:-r-Apache2::RequestRec-object8">obj: <code>$r</code> ( <code><a>Apache2::RequestRec object</a></code> )</dt>
<dd>
<p>The current request</p>
</dd>
<dt id="ret:-no-return-value1">ret: no return value</dt>
<dd>
</dd>
<dt id="since:-2.0.007">since: 2.0.00</dt>
<dd>
</dd>
</dl>
<p>This method requires <code>AuthType</code> to be set to <code>Basic</code> or <code>Digest</code>. Depending on the setting it'll call either <code><a href="#C_note_basic_auth_failure_">$r->note_basic_auth_failure</a></code> or <code><a href="#C_note_digest_auth_failure_">$r->note_digest_auth_failure</a></code>.</p>
<h2 id="note_basic_auth_failure"><code>note_basic_auth_failure</code></h2>
<p>Setup the output headers so that the client knows how to authenticate itself the next time, if an authentication request failed. This function works only for basic authentication</p>
<pre><code> $r->note_basic_auth_failure();</code></pre>
<dl>
<dt id="obj:-r-Apache2::RequestRec-object9">obj: <code>$r</code> ( <code><a>Apache2::RequestRec object</a></code> )</dt>
<dd>
<p>The current request</p>
</dd>
<dt id="ret:-no-return-value2">ret: no return value</dt>
<dd>
</dd>
<dt id="since:-2.0.008">since: 2.0.00</dt>
<dd>
</dd>
</dl>
<h2 id="note_digest_auth_failure"><code>note_digest_auth_failure</code></h2>
<p>Setup the output headers so that the client knows how to authenticate itself the next time, if an authentication request failed. This function works only for digest authentication.</p>
<pre><code> $r->note_digest_auth_failure();</code></pre>
<dl>
<dt id="obj:-r-Apache2::RequestRec-object10">obj: <code>$r</code> ( <code><a>Apache2::RequestRec object</a></code> )</dt>
<dd>
<p>The current request</p>
</dd>
<dt id="ret:-no-return-value3">ret: no return value</dt>
<dd>
</dd>
<dt id="since:-2.0.009">since: 2.0.00</dt>
<dd>
</dd>
</dl>
<h2 id="requires"><code>requires</code></h2>
<p>Retrieve information about all of the requires directives for this request</p>
<pre><code> $requires = $r->requires</code></pre>
<dl>
<dt id="obj:-r-Apache2::RequestRec-object11">obj: <code>$r</code> ( <code><a>Apache2::RequestRec object</a></code> )</dt>
<dd>
<p>The current request</p>
</dd>
<dt id="ret:-requires-ARRAY-ref">ret: <code>$requires</code> ( ARRAY ref )</dt>
<dd>
<p>Returns an array reference of hash references, containing information related to the <code>require</code> directive.</p>
</dd>
<dt id="since:-2.0.0010">since: 2.0.00</dt>
<dd>
</dd>
</dl>
<p>This is normally used for access control.</p>
<p>For example if the configuration had the following require directives:</p>
<pre><code> Require user goo bar
Require group bar tar</code></pre>
<p>this method will return the following datastructure:</p>
<pre><code> [
{
'method_mask' => -1,
'requirement' => 'user goo bar'
},
{
'method_mask' => -1,
'requirement' => 'group bar tar'
}
];</code></pre>
<p>The <i>requirement</i> field is what was passed to the <code>Require</code> directive. The <i>method_mask</i> field is a bitmask which can be modified by the <code>Limit</code> directive, but normally it can be safely ignored as it's mostly used internally. For example if the configuration was:</p>
<pre><code> Require user goo bar
Require group bar tar
<Limit POST>
Require valid-user
</Limit></code></pre>
<p>and the request method was <code>POST</code>, <code>$r->requires</code> will return:</p>
<pre><code> [
{
'method_mask' => -1,
'requirement' => 'user goo bar'
},
{
'method_mask' => -1,
'requirement' => 'group bar tar'
}
{
'method_mask' => 4,
'requirement' => 'valid-user'
}
];</code></pre>
<p>But if the request method was <code>GET</code>, it will return only:</p>
<pre><code> [
{
'method_mask' => -1,
'requirement' => 'user goo bar'
},
{
'method_mask' => -1,
'requirement' => 'group bar tar'
}
];</code></pre>
<p>As you can see Apache gives you the requirements relevant for the current request, so the <i>method_mask</i> is irrelevant.</p>
<p>It is also a good time to remind that in the general case, access control directives should not be placed within a <Limit> section. Refer to the Apache documentation for more information.</p>
<p>Using the same configuration and assuming that the request was of type POST, the following code inside an Auth handler:</p>
<pre><code> my %require =
map { my ($k, $v) = split /\s+/, $_->{requirement}, 2; ($k, $v||'') }
@{ $r->requires };</code></pre>
<p>will populate <code>%require</code> with the following pairs:</p>
<pre><code> 'group' => 'bar tar',
'user' => 'goo bar',
'valid-user' => '',</code></pre>
<h2 id="satisfies"><code>satisfies</code></h2>
<p>How the requires lines must be met. What's the applicable value of the <code>Satisfy</code> directive:</p>
<pre><code> $satisfy = $r->satisfies();</code></pre>
<dl>
<dt id="obj:-r-Apache2::RequestRec-object12">obj: <code>$r</code> ( <code><a>Apache2::RequestRec object</a></code> )</dt>
<dd>
<p>The current request</p>
</dd>
<dt id="ret:-satisfy-integer">ret: <code>$satisfy</code> ( integer )</dt>
<dd>
<p>How the requirements must be met. One of the <code><a>Apache2::Const :satisfy constants</a></code>:</p>
<p><code><a>Apache2::Const::SATISFY_ANY</a></code>, <code><a>Apache2::Const::SATISFY_ALL</a></code> and <code><a>Apache2::Const::SATISFY_NOSPEC</a></code>.</p>
</dd>
<dt id="since:-2.0.0011">since: 2.0.00</dt>
<dd>
</dd>
</dl>
<p>See the documentation for the <code>Satisfy</code> directive in the Apache documentation.</p>
<h2 id="some_auth_required"><code>some_auth_required</code></h2>
<p>Can be used within any handler to determine if any authentication is required for the current request:</p>
<pre><code> $need_auth = $r->some_auth_required();</code></pre>
<dl>
<dt id="obj:-r-Apache2::RequestRec-object13">obj: <code>$r</code> ( <code><a>Apache2::RequestRec object</a></code> )</dt>
<dd>
<p>The current request</p>
</dd>
<dt id="ret:-need_auth-boolean">ret: <code>$need_auth</code> ( boolean )</dt>
<dd>
<p>TRUE if authentication is required, FALSE otherwise</p>
</dd>
<dt id="since:-2.0.0012">since: 2.0.00</dt>
<dd>
</dd>
</dl>
<h1 id="See-Also">See Also</h1>
<p><a>mod_perl 2.0 documentation</a>.</p>
<h1 id="Copyright">Copyright</h1>
<p>mod_perl 2.0 and its core modules are copyrighted under The Apache Software License, Version 2.0.</p>
<h1 id="Authors">Authors</h1>
<p><a>The mod_perl development team and numerous contributors</a>.</p>
</body>
</html>
|