/* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.
*/
/** * Structure to carry the per-dir session config.
*/ typedefstruct { constchar *name; int name_set; constchar *name_attrs; constchar *name2; int name2_set; constchar *name2_attrs; int remove; int remove_set;
} session_cookie_dir_conf;
/** * Set the cookie and embed the session within it. * * This function adds an RFC2109 compliant Set-Cookie header for * the cookie specified in SessionCookieName, and an RFC2965 compliant * Set-Cookie2 header for the cookie specified in SessionCookieName2. * * If specified, the optional cookie attributes will be added to * each cookie. If defaults are not specified, DEFAULT_ATTRS * will be used. * * On success, this method will return APR_SUCCESS. * * @param r The request pointer. * @param z A pointer to where the session will be written.
*/ static apr_status_t session_cookie_save(request_rec * r, session_rec * z)
{
if (conf->name_set || conf->name2_set) { return OK;
} return DECLINED;
}
/** * Isolate the cookie with the name "name", and if present, extract * the payload from the cookie. * * If the cookie is found, the cookie and any other cookies with the * same name are removed from the cookies passed in the request, so * that credentials are not leaked to a backend server or process. * * A missing or malformed cookie will cause this function to return * APR_EGENERAL. * * On success, this returns APR_SUCCESS.
*/ static apr_status_t session_cookie_load(request_rec * r, session_rec ** z)
{
/* find the first redirect */ while (m->prev) {
m = m->prev;
} /* find the main request */ while (m->main) {
m = m->main;
}
/* is our session in a cookie? */ if (conf->name2_set) {
name = conf->name2;
} elseif (conf->name_set) {
name = conf->name;
} else { return DECLINED;
}
/* first look in the notes */
note = apr_pstrcat(m->pool, MOD_SESSION_COOKIE, name, NULL);
zz = (session_rec *)apr_table_get(m->notes, note); if (zz) {
*z = zz; return OK;
}
/** * Sanity check a given string that it exists, is not empty, * and does not contain special characters.
*/ staticconstchar *check_string(cmd_parms * cmd, constchar *string)
{ if (!string || !*string || ap_strchr_c(string, '=') || ap_strchr_c(string, '&')) { return apr_pstrcat(cmd->pool, cmd->directive->directive, " cannot be empty, or contain '=' or '&'.",
NULL);
} return NULL;
}
staticconst command_rec session_cookie_cmds[] =
{
AP_INIT_RAW_ARGS("SessionCookieName", set_cookie_name, NULL, RSRC_CONF|OR_AUTHCFG, "The name of the RFC2109 cookie carrying the session"),
AP_INIT_RAW_ARGS("SessionCookieName2", set_cookie_name2, NULL, RSRC_CONF|OR_AUTHCFG, "The name of the RFC2965 cookie carrying the session"),
AP_INIT_FLAG("SessionCookieRemove", set_remove, NULL, RSRC_CONF|OR_AUTHCFG, "Set to 'On' to remove the session cookie from the headers " "and hide the cookie from a backend server or process"),
{NULL}
};
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.