Text of httpd.apache.org › docs › current › mod › mod_authz_core.html as Styx crawled it on Nov 18, 2026. The page may have changed since. Only its words are kept, without pictures or layout, and only the first part of a long page.

Open the live page

mod_authz_core - Apache HTTP Server Version 2.4

Modules | Directives | FAQ | Glossary | Sitemap | Report a bug Apache HTTP Server Version 2.4 Apache > HTTP Server > Documentation > Version 2.4 > Modules Apache Module mod_authz_core Available Languages: en | fr Description: Core Authorization Status: Base Module Identifier: authz_core_module Source File: mod_authz_core.c Compatibility: Available in Apache HTTPD 2.3 and later Summary This module provides core authorization capabilities so that authenticated users can be allowed or denied access to portions of the web site. mod_authz_core provides the functionality to register various authorization providers.

It is usually used in conjunction with an authentication provider module such as mod_authn_file and an authorization module such as mod_authz_user . It also allows for advanced logic to be applied to the authorization processing. Topics Authorization Containers Authorization Result States The Require Directives Creating Authorization Provider Aliases Directives AuthMerging <AuthzProviderAlias> AuthzSendForbiddenOnFailure Require <RequireAll> <RequireAny> <RequireNone> Bugfix checklist httpd changelog Known issues Report a bug Authorization Containers ¶ The authorization container directives <RequireAll> , <RequireAny> and <RequireNone> may be combined with each other and with the Require directive to express complex authorization logic.

The example below expresses the following authorization logic. In order to access the resource, the user must either be the superadmin user, or belong to both the admins group and the Administrators LDAP group and either belong to the sales group or have the LDAP dept attribute sales . Furthermore, in order to access the resource, the user must not belong to either the temps group or the LDAP group Temporary Employees . <Directory "/www/mydocs"> <RequireAll> <RequireAny> Require user superadmin <RequireAll> Require group admins Require ldap-group "cn=Administrators,o=Airius" <RequireAny> Require group sales Require ldap-attribute dept="sales" </RequireAny> </RequireAll> </RequireAny> <RequireNone> Require group temps Require ldap-group "cn=Temporary Employees,o=Airius" </RequireNone> </RequireAll> </Directory> Authorization Result States ¶ Each authorization provider returns one of three possible results when evaluating a Require directive: Granted The provider has verified that the request meets its requirements.

Denied The provider has determined that the request does not meet its requirements. Neutral The provider has no opinion about the request. This can occur when a provider is not relevant to the request (e.g., a group-membership check when the request does not involve group-based authorization). The authorization container directives interpret these three results as follows: Container Granted if... Denied if... Neutral treated as... <RequireAny> at least one provider grants all providers deny deny (does not satisfy the requirement) <RequireAll> no provider denies (and at least one grants) any provider denies grant (does not block the requirement) <RequireNone> no provider grants any provider grants grant (does not block) When a Require directive is negated with not (e.g., Require not group temps ), a granted result is inverted to denied and vice versa, but a neutral result remains neutral.

A negated directive can therefore never independently authorize a request. The Require Directives ¶ mod_authz_core provides some generic authorization providers which can be used with the Require directive. Require env The env provider allows access to the server to be controlled based on the existence of an environment variable . When Require env env-variable is specified, then the request is allowed access if the environment variable env-variable exists.

The server provides the ability to set environment variables in a flexible way based on characteristics of the client request using the directives provided by mod_setenvif . Therefore, this directive can be used to allow access based on such factors as the clients User-Agent (browser type), Referer , or other HTTP request header fields. SetEnvIf User-Agent "^KnockKnock/2\.0" let_me_in <Directory "/docroot"> Require env let_me_in </Directory> In this case, browsers with a user-agent string beginning with KnockKnock/2.0 will be allowed access, and all others will be denied.

When the server looks up a path via an internal subrequest such as looking for a DirectoryIndex or generating a directory listing with mod_autoindex , per-request environment variables are not inherited in the subrequest. Additionally, SetEnvIf directives are not separately evaluated in the subrequest due to the API phases mod_setenvif takes action in. Require all The all provider mimics the functionality that was previously provided by the 'Allow from all' and 'Deny from all' directives.

This provider can take one of two arguments which are 'granted' or 'denied'. The following examples will grant or deny access to all requests. Require all granted Require all denied Require method The method provider allows using the HTTP method in authorization decisions. The GET and HEAD methods are treated as equivalent. The TRACE method is not available to this provider, use TraceEnable instead. The following example will only allow GET, HEAD, POST, and OPTIONS requests: Require method GET POST OPTIONS The following example will allow GET, HEAD, POST, and OPTIONS requests without authentication, and require a valid user for all other methods: <RequireAny> Require method GET POST OPTIONS Require valid-user </RequireAny> Require expr The expr provider allows basing authorization decisions on arbitrary expressions.

Require expr "%{TIME_HOUR} -ge 9 && %{TIME_HOUR} -le 17" <RequireAll> Require expr "!(%{QUERY_STRING} =~ /secret/)" Require expr "%{REQUEST_URI} in { '/example.cgi', '/other.cgi' }" </RequireAll> Require expr "!(%{QUERY_STRING} =~ /secret/) && %{REQUEST_URI} in { '/example.cgi', '/other.cgi' }" The syntax is described in the ap_expr documentation. Before httpd 2.4.16, the surrounding double-quotes MUST be omitted. Normally, the expression is evaluated before authentication.

However, if the expression returns false and references the variable %{REMOTE_USER} , authentication will be performed and the expression will be re-evaluated. Creating Authorization Provider Aliases ¶ Extended authorization providers can be created within the configuration file and assigned an alias name. The alias providers can then be referenced through the Require directive in the same way as a base authorization provider.

Besides the ability to create and alias an extended provider, it also allows the same extended authorization provider to be referenced by multiple locations. Example The example below creates two different ldap authorization provider aliases based on the ldap-group authorization provider. This example allows a single authorization location to check group membership within multiple ldap hosts: <AuthzProviderAlias ldap-group ldap-group-alias1 "cn=my-group,o=ctx"> AuthLDAPBindDN "cn=youruser,o=ctx" AuthLDAPBindPassword yourpassword AuthLDAPUrl "ldap://ldap.host/o=ctx" </AuthzProviderAlias> <AuthzProviderAlias ldap-group ldap-group-alias2 "cn=my-other-group,o=dev"> AuthLDAPBindDN "cn=yourotheruser,o=dev" AuthLDAPBindPassword yourotherpassword AuthLDAPUrl "ldap://other.ldap.host/o=dev?cn" </AuthzProviderAlias> Alias "/secure" "/webpages/secure" <Directory "/webpages/secure"> AuthType Basic AuthName "LDAP Protected" AuthBasicProvider ldap AuthLDAPUrl "ldap://ldap.host/o=ctx" #implied OR operation Require ldap-group-alias1 Require ldap-group-alias2 </Directory> AuthMerging Directive ¶ Description: Controls the manner in which each configuration section's authorization logic is combined with that of preceding configuration sections.

Syntax: AuthMerging Off | And | Or Default: AuthMerging Off Context: directory, .htaccess Override: AuthConfig Status: Base Module: mod_authz_core When authorization is enabled, it is

The rest of this page is on the live site.