apache2::access.3

来自「视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.」· 3 代码 · 共 663 行 · 第 1/2 页

3
663
字号
which authentication credentials to send with each \s-1HTTP\s0 request. Thesecredentials are tagged with the name of the authentication realm thatcreated them.  Then during the authentication stage the server usesthe current authentication realm, from \f(CW\*(C`$r\->auth_name\*(C'\fR, todetermine which set of credentials to authenticate..ie n .Sh """auth_type""".el .Sh "\f(CWauth_type\fP".IX Subsection "auth_type"Get/set the type of authorization required for this request (the perdirectory configuration directive \f(CW\*(C`AuthType\*(C'\fR):.PP.Vb 2\&  $auth_type = $r\->auth_type();\&  $auth_type = $r\->auth_type($new_auth_type);.Ve.ie n .IP "obj: $r\fR ( \f(CW""Apache2::RequestRec object"" )" 4.el .IP "obj: \f(CW$r\fR ( \f(CWApache2::RequestRec object\fR )" 4.IX Item "obj: $r ( Apache2::RequestRec object )"The current request.ie n .IP "opt arg1: $new_auth_type ( string )" 4.el .IP "opt arg1: \f(CW$new_auth_type\fR ( string )" 4.IX Item "opt arg1: $new_auth_type ( string )"If \f(CW$new_auth_type\fR is passed a new \f(CW\*(C`AuthType\*(C'\fR value is set.ie n .IP "ret: ""$"" ( integer )" 4.el .IP "ret: \f(CW$\fR ( integer )" 4.IX Item "ret: $ ( integer )"The current value of \f(CW\*(C`AuthType\*(C'\fR.IP "since: 2.0.00" 4.IX Item "since: 2.0.00".PPNormally \f(CW\*(C`AuthType\*(C'\fR would be set to \f(CW\*(C`Basic\*(C'\fR to use the basicauthentication scheme defined in \s-1RFC\s0 1945, \fIHypertext TransferProtocol \*(-- \s-1HTTP/1\s0.0\fR. However, you could set to something else andimplement your own authentication scheme..ie n .Sh """get_basic_auth_pw""".el .Sh "\f(CWget_basic_auth_pw\fP".IX Subsection "get_basic_auth_pw"Get the password from the request headers.PP.Vb 1\&  my ($rc, $passwd) = $r\->get_basic_auth_pw();.Ve.ie n .IP "obj: $r\fR ( \f(CW""Apache2::RequestRec object"" )" 4.el .IP "obj: \f(CW$r\fR ( \f(CWApache2::RequestRec object\fR )" 4.IX Item "obj: $r ( Apache2::RequestRec object )"The current request.ie n .IP "ret1: $rc\fR ( \f(CW""Apache2::Const constant"" )" 4.el .IP "ret1: \f(CW$rc\fR ( \f(CWApache2::Const constant\fR )" 4.IX Item "ret1: $rc ( Apache2::Const constant )"\&\f(CW\*(C`Apache2::Const::OK\*(C'\fR if the \f(CW$passwd\fR value is set (and assured a correctvalue in\&\f(CW\*(C`$r\->user\*(C'\fR);otherwise it returns an error code, either\&\f(CW\*(C`Apache2::Const::HTTP_INTERNAL_SERVER_ERROR\*(C'\fR if things are really confused,\&\f(CW\*(C`Apache2::Const::HTTP_UNAUTHORIZED\*(C'\fR if no authentication at all seemed to bein use, or \f(CW\*(C`Apache2::Const::DECLINED\*(C'\fR if there was authentication, but itwasn't \f(CW\*(C`Basic\*(C'\fR (in which case, the caller should presumably declineas well)..ie n .IP "ret2: $ret (string)" 4.el .IP "ret2: \f(CW$ret\fR (string)" 4.IX Item "ret2: $ret (string)"The password as set in the headers (decoded).IP "since: 2.0.00" 4.IX Item "since: 2.0.00".PPIf \f(CW\*(C`AuthType\*(C'\fR is not set, this handler first sets itto \f(CW\*(C`Basic\*(C'\fR..ie n .Sh """get_remote_logname""".el .Sh "\f(CWget_remote_logname\fP".IX Subsection "get_remote_logname"Retrieve the login name of the remote user (\s-1RFC1413\s0).PP.Vb 1\&  $remote_logname = $r\->get_remote_logname();.Ve.ie n .IP "obj: $r\fR ( \f(CW""Apache2::RequestRec object"" )" 4.el .IP "obj: \f(CW$r\fR ( \f(CWApache2::RequestRec object\fR )" 4.IX Item "obj: $r ( Apache2::RequestRec object )"The current request.ie n .IP "ret: $remote_logname ( string )" 4.el .IP "ret: \f(CW$remote_logname\fR ( string )" 4.IX Item "ret: $remote_logname ( string )"The username of the user logged in to the client machine, or an emptystring if it could not be determined via \s-1RFC1413\s0, which involvesquerying the client's identd or auth daemon..IP "since: 2.0.00" 4.IX Item "since: 2.0.00".PPDo not confuse this method with\&\f(CW\*(C`$r\->user\*(C'\fR, whichprovides the username provided by the user during the serverauthentication..ie n .Sh """note_auth_failure""".el .Sh "\f(CWnote_auth_failure\fP".IX Subsection "note_auth_failure"Setup the output headers so that the client knows how to authenticateitself the next time, if an authentication request failed.  Thisfunction works for both basic and digest authentication.PP.Vb 1\&  $r\->note_auth_failure();.Ve.ie n .IP "obj: $r\fR ( \f(CW""Apache2::RequestRec object"" )" 4.el .IP "obj: \f(CW$r\fR ( \f(CWApache2::RequestRec object\fR )" 4.IX Item "obj: $r ( Apache2::RequestRec object )"The current request.IP "ret: no return value" 4.IX Item "ret: no return value".PD 0.IP "since: 2.0.00" 4.IX Item "since: 2.0.00".PD.PPThis method requires \f(CW\*(C`AuthType\*(C'\fR to be set to \f(CW\*(C`Basic\*(C'\fR or\&\f(CW\*(C`Digest\*(C'\fR. Depending on the setting it'll call either\&\f(CW\*(C`$r\->note_basic_auth_failure\*(C'\fR or\&\f(CW\*(C`$r\->note_digest_auth_failure\*(C'\fR..ie n .Sh """note_basic_auth_failure""".el .Sh "\f(CWnote_basic_auth_failure\fP".IX Subsection "note_basic_auth_failure"Setup the output headers so that the client knows how to authenticateitself the next time, if an authentication request failed.  Thisfunction works only for basic authentication.PP.Vb 1\&  $r\->note_basic_auth_failure();.Ve.ie n .IP "obj: $r\fR ( \f(CW""Apache2::RequestRec object"" )" 4.el .IP "obj: \f(CW$r\fR ( \f(CWApache2::RequestRec object\fR )" 4.IX Item "obj: $r ( Apache2::RequestRec object )"The current request.IP "ret: no return value" 4.IX Item "ret: no return value".PD 0.IP "since: 2.0.00" 4.IX Item "since: 2.0.00".PD.ie n .Sh """note_digest_auth_failure""".el .Sh "\f(CWnote_digest_auth_failure\fP".IX Subsection "note_digest_auth_failure"Setup the output headers so that the client knows how to authenticateitself the next time, if an authentication request failed.  Thisfunction works only for digest authentication..PP.Vb 1\&  $r\->note_digest_auth_failure();.Ve.ie n .IP "obj: $r\fR ( \f(CW""Apache2::RequestRec object"" )" 4.el .IP "obj: \f(CW$r\fR ( \f(CWApache2::RequestRec object\fR )" 4.IX Item "obj: $r ( Apache2::RequestRec object )"The current request.IP "ret: no return value" 4.IX Item "ret: no return value".PD 0.IP "since: 2.0.00" 4.IX Item "since: 2.0.00".PD.ie n .Sh """requires""".el .Sh "\f(CWrequires\fP".IX Subsection "requires"Retrieve information about all of the requires directives for this request.PP.Vb 1\&  $requires = $r\->requires.Ve.ie n .IP "obj: $r\fR ( \f(CW""Apache2::RequestRec object"" )" 4.el .IP "obj: \f(CW$r\fR ( \f(CWApache2::RequestRec object\fR )" 4.IX Item "obj: $r ( Apache2::RequestRec object )"The current request.ie n .IP "ret: $requires ( \s-1ARRAY\s0 ref )" 4.el .IP "ret: \f(CW$requires\fR ( \s-1ARRAY\s0 ref )" 4.IX Item "ret: $requires ( ARRAY ref )"Returns an array reference of hash references, containing informationrelated to the \f(CW\*(C`require\*(C'\fR directive..IP "since: 2.0.00" 4.IX Item "since: 2.0.00".PPThis is normally used for access control..PPFor example if the configuration had the following require directives:.PP.Vb 2\&    Require user  goo bar\&    Require group bar tar.Ve.PPthis method will return the following datastructure:.PP.Vb 10\&  [\&    {\&      \*(Aqmethod_mask\*(Aq => \-1,\&      \*(Aqrequirement\*(Aq => \*(Aquser goo bar\*(Aq\&    },\&    {\&      \*(Aqmethod_mask\*(Aq => \-1,\&      \*(Aqrequirement\*(Aq => \*(Aqgroup bar tar\*(Aq\&    }\&  ];.Ve.PPThe \fIrequirement\fR field is what was passed to the \f(CW\*(C`Require\*(C'\fRdirective.  The \fImethod_mask\fR field is a bitmask which can bemodified by the \f(CW\*(C`Limit\*(C'\fR directive, but normally it can be safelyignored as it's mostly used internally. For example if theconfiguration was:.PP.Vb 5\&    Require user goo bar\&    Require group bar tar\&    <Limit POST>\&       Require valid\-user\&    </Limit>.Ve.PPand the request method was \f(CW\*(C`POST\*(C'\fR, \f(CW\*(C`$r\->requires\*(C'\fR will return:.PP.Vb 10\&  [\&    {\&      \*(Aqmethod_mask\*(Aq => \-1,\&      \*(Aqrequirement\*(Aq => \*(Aquser goo bar\*(Aq\&    },\&    {\&      \*(Aqmethod_mask\*(Aq => \-1,\&      \*(Aqrequirement\*(Aq => \*(Aqgroup bar tar\*(Aq\&    }\&    {\&      \*(Aqmethod_mask\*(Aq => 4,\&      \*(Aqrequirement\*(Aq => \*(Aqvalid\-user\*(Aq\&    }\&  ];.Ve.PPBut if the request method was \f(CW\*(C`GET\*(C'\fR, it will return only:.PP.Vb 10\&  [\&    {\&      \*(Aqmethod_mask\*(Aq => \-1,\&      \*(Aqrequirement\*(Aq => \*(Aquser goo bar\*(Aq\&    },\&    {\&      \*(Aqmethod_mask\*(Aq => \-1,\&      \*(Aqrequirement\*(Aq => \*(Aqgroup bar tar\*(Aq\&    }\&  ];.Ve.PPAs you can see Apache gives you the requirements relevant for thecurrent request, so the \fImethod_mask\fR is irrelevant..PPIt is also a good time to remind that in the general case, accesscontrol directives should not be placed within a <Limit>section.  Refer to the Apache documentation for more information..PPUsing the same configuration and assuming that the request was of type\&\s-1POST\s0, the following code inside an Auth handler:.PP.Vb 3\&  my %require =\&      map { my ($k, $v) = split /\es+/, $_\->{requirement}, 2; ($k, $v||\*(Aq\*(Aq) }\&      @{ $r\->requires };.Ve.PPwill populate \f(CW%require\fR with the following pairs:.PP.Vb 3\&  \*(Aqgroup\*(Aq => \*(Aqbar tar\*(Aq,\&  \*(Aquser\*(Aq => \*(Aqgoo bar\*(Aq,\&  \*(Aqvalid\-user\*(Aq => \*(Aq\*(Aq,.Ve.ie n .Sh """satisfies""".el .Sh "\f(CWsatisfies\fP".IX Subsection "satisfies"How the requires lines must be met. What's the applicable value of the\&\f(CW\*(C`Satisfy\*(C'\fR directive:.PP.Vb 1\&  $satisfy = $r\->satisfies();.Ve.ie n .IP "obj: $r\fR ( \f(CW""Apache2::RequestRec object"" )" 4.el .IP "obj: \f(CW$r\fR ( \f(CWApache2::RequestRec object\fR )" 4.IX Item "obj: $r ( Apache2::RequestRec object )"The current request.ie n .IP "ret: $satisfy ( integer )" 4.el .IP "ret: \f(CW$satisfy\fR ( integer )" 4.IX Item "ret: $satisfy ( integer )"How the requirements must be met.  One of the \f(CW\*(C`Apache2::Const:satisfy constants\*(C'\fR:.Sp\&\f(CW\*(C`Apache2::Const::SATISFY_ANY\*(C'\fR,\&\f(CW\*(C`Apache2::Const::SATISFY_ALL\*(C'\fRand\&\f(CW\*(C`Apache2::Const::SATISFY_NOSPEC\*(C'\fR..IP "since: 2.0.00" 4.IX Item "since: 2.0.00".PPSee the documentation for the \f(CW\*(C`Satisfy\*(C'\fR directive in the Apachedocumentation..ie n .Sh """some_auth_required""".el .Sh "\f(CWsome_auth_required\fP".IX Subsection "some_auth_required"Can be used within any handler to determine if any authentication isrequired for the current request:.PP.Vb 1\&  $need_auth = $r\->some_auth_required();.Ve.ie n .IP "obj: $r\fR ( \f(CW""Apache2::RequestRec object"" )" 4.el .IP "obj: \f(CW$r\fR ( \f(CWApache2::RequestRec object\fR )" 4.IX Item "obj: $r ( Apache2::RequestRec object )"The current request.ie n .IP "ret: $need_auth ( boolean )" 4.el .IP "ret: \f(CW$need_auth\fR ( boolean )" 4.IX Item "ret: $need_auth ( boolean )"\&\s-1TRUE\s0 if authentication is required, \s-1FALSE\s0 otherwise.IP "since: 2.0.00" 4.IX Item "since: 2.0.00".SH "See Also".IX Header "See Also"mod_perl 2.0 documentation..SH "Copyright".IX Header "Copyright"mod_perl 2.0 and its core modules are copyrighted underThe Apache Software License, Version 2.0..SH "Authors".IX Header "Authors"The mod_perl development team and numerouscontributors.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?