Раздел 10. Apache modules Пункты: 85 86 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 163 164 165 166 167 168 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 203 204 205 206 207 208 209 210 211 212 213 RU EN Пункт 108. Apache Module mod_authn_socache
SummaryMaintains a cache of authentication credentials, so that a new backend lookup is not required for every authenticated request. Authentication CacheingSome users of more heavyweight authentication such as SQL database
lookups ( mod_authn_socache provides a solution to this problem by maintaining a cache of authentication credentials. UsageThe authentication cache should be used where authentication
lookups impose a significant load on the server, or a backend or
network. Authentication by file ( The basic rules to cache for a provider are:
A simple usage example to accelerate #AuthnCacheSOCache is optional. If specified, it is server-wide AuthnCacheSOCache dbm <Directory "/usr/www/myhost/private"> AuthType Basic AuthName "Cached Authentication Example" AuthBasicProvider socache dbd AuthDBDUserPWQuery "SELECT password FROM authn WHERE user = %s" AuthnCacheProvideFor dbd Require valid-user #Optional AuthnCacheContext dbd-authn-example </Directory> Cacheing with custom modulesModule developers should note that their modules must be enabled for cacheing with mod_authn_socache. A single optional API function ap_authn_cache_store is provided to cache credentials a provider has just looked up or generated. Usage examples are available in r957072, in which three authn providers are enabled for cacheing. AuthnCacheContext Directive
This directive specifies a string to be used along with the supplied username (and realm in the case of Digest Authentication) in constructing a cache key. This serves to disambiguate identical usernames serving different authentication areas on the server. Two special values for this are directory, which uses the directory context of the request as a string, and server which uses the virtual host name. The default is directory, which is also the most
conservative setting. This is likely to be less than optimal, as it
(for example) causes $app-base, $app-base/images,
$app-base/scripts and $app-base/media each to
have its own separate cache key. A better policy is to name the
Contexts can be shared across different areas of a server, where credentials are shared. However, this has potential to become a vector for cross-site or cross-application security breaches, so this directive is not permitted in .htaccess contexts. AuthnCacheEnable Directive
This directive is not normally necessary: it is implied if authentication cacheing is enabled anywhere in apache2.conf. However, if it is not enabled anywhere in apache2.conf it will by default not be initialised, and is therefore not available in a .htaccess context. This directive ensures it is initialised so it can be used in .htaccess. AuthnCacheProvideFor Directive
This directive specifies an authentication provider or providers to cache for. Credentials found by a provider not listed in an AuthnCacheProvideFor directive will not be cached. For example, to cache credentials found by AuthnCacheProvideFor dbd myprovider AuthnCacheSOCache Directive
This is a server-wide setting to select a provider for the shared object cache, followed by optional arguments for that provider. Some possible values for provider-name are "dbm", "dc", "memcache", or "shmcb", each subject to the appropriate module being loaded. If not set, your platform's default will be used. AuthnCacheTimeout Directive
Cacheing authentication data can be a security issue, though short-term cacheing is unlikely to be a problem. Typically a good solution is to cache credentials for as long as it takes to relieve the load on a backend, but no longer, though if changes to your users and passwords are infrequent then a longer timeout may suit you. The default 300 seconds (5 minutes) is both cautious and ample to keep the load on a backend such as dbd (SQL database queries) down. This should not be confused with session timeout, which is an entirely separate issue. However, you may wish to check your session-management software for whether cached credentials can "accidentally" extend a session, and bear it in mind when setting your timeout. Пункты: 85 86 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 163 164 165 166 167 168 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 203 204 205 206 207 208 209 210 211 212 213 |
![]() |