authtktauthenticationpolicy¶
When this directive is used, authentication information is obtained
from an paste.auth.auth_tkt cookie value, assumed to be set by
a custom login form.
Attributes¶
secret- The
secretis a string that will be used to sign the data stored by the cookie. It is required and has no default. callback- The
callbackis a Python dotted name to a function passed the string representing the userid stored in the cookie and the request as positional arguments. The callback is expected to return None if the user represented by the string doesn’t exist or a sequence of group identifiers (possibly empty) if the user does exist. Ifcallbackis None, the userid will be assumed to exist with no groups. It defaults toNone. cookie_name- The
cookie_nameis the name used for the cookie that contains the user information. It defaults toauth_tkt. securesecureis a boolean value. If it’s set to “true”, the cookie will only be sent back by the browser over a secure (HTTPS) connection. It defaults to “false”.include_ipinclude_ipis a boolean value. If it’s set to true, the requesting IP address is made part of the authentication data in the cookie; if the IP encoded in the cookie differs from the IP of the requesting user agent, the cookie is considered invalid. It defaults to “false”.timeouttimeoutis an integer value. It represents the maximum age in seconds which the auth_tkt ticket will be considered valid. Iftimeoutis specified, andreissue_timeis also specified,reissue_timemust be a smaller value thantimeout. It defaults toNone, meaning that the ticket will be considered valid forever.reissue_timereissue_timeis an integer value. Ifreissue_timeis specified, when we encounter a cookie that is older than the reissue time (in seconds), but younger that thetimeout, a new cookie will be issued. It defaults toNone, meaning that authentication cookies are never reissued. A value of0means reissue a cookie in the response to every request that requires authentication.max_agemax_ageis the maximum age of the auth_tkt cookie, in seconds. This differs fromtimeoutinasmuch astimeoutrepresents the lifetime of the ticket contained in the cookie, while this value represents the lifetime of the cookie itself. When this value is set, the cookie’sMax-AgeandExpiressettings will be set, allowing the auth_tkt cookie to last between browser sessions. It is typically nonsensical to set this to a value that is lower thantimeoutorreissue_time, although it is not explicitly prevented. It defaults toNone, meaning (on all major browser platforms) that auth_tkt cookies will last for the lifetime of the user’s browser session.wild_domain- A boolean value. If it’s set to “true”, a cookie with a “wild” domain
value will only be sent back by the browser during
remember. It defaults to “true”.
Example¶
1 2 3 4 5 6 7 8 9 10 11 | <authtktauthenticationpolicy
secret="goshiamsosecret"
callback=".somemodule.somefunc"
cookie_name="mycookiename"
secure="false"
include_ip="false"
timeout="86400"
reissue_time="600"
max_age="31536000"
wild_domain="true"
/>
|
Alternatives¶
You may create an instance of the
pyramid.authentication.AuthTktAuthenticationPolicy and
pass it to the pyramid.config.Configurator
constructor as the authentication_policy argument during initial
application configuration.