mod_session_cookie.c revision d6e81217d873dc3b87fc4ffa5fbac2fad4191a15
/* 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
*
*
* 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.
*/
#include "mod_session.h"
#include "apr_lib.h"
#include "apr_strings.h"
#include "http_log.h"
#include "util_cookies.h"
#define LOG_PREFIX "mod_session_cookie: "
#define MOD_SESSION_COOKIE "mod_session_cookie"
/**
* Structure to carry the per-dir session config.
*/
typedef struct {
const char *name;
int name_set;
const char *name_attrs;
const char *name2;
int name2_set;
const char *name2_attrs;
int remove;
int remove_set;
/**
* 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.
*/
{
/* don't cache auth protected pages */
/* create RFC2109 compliant cookie */
}
else {
}
}
/* create RFC2965 compliant cookie */
}
else {
}
}
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.
*/
{
/* is our session in a cookie? */
}
}
else {
return DECLINED;
}
/* first look in the notes */
if (zz) {
*z = zz;
return OK;
}
/* otherwise, try parse the cookie */
/* create a new session and return it */
*z = zz;
/* put the session in the notes so we don't have to parse it again */
return OK;
}
{
return (void *) new;
}
{
session_cookie_dir_conf *new = (session_cookie_dir_conf *) apr_pcalloc(p, sizeof(session_cookie_dir_conf));
return new;
}
/**
* Sanity check a given string that it exists, is not empty,
* and does not contain special characters.
*/
{
" cannot be empty, or contain '=' or '&'.",
NULL);
}
return NULL;
}
{
char *last;
while (apr_isspace(*last)) {
last++;
}
}
{
char *last;
while (apr_isspace(*last)) {
last++;
}
}
static const char *
{
return NULL;
}
static const command_rec session_cookie_cmds[] =
{
"The name of the RFC2109 cookie carrying the session"),
"The name of the RFC2965 cookie carrying the session"),
"Set to 'On' to remove the session cookie from the headers "
"and hide the cookie from a backend server or process"),
{NULL}
};
static void register_hooks(apr_pool_t * p)
{
}
{
create_session_cookie_dir_config, /* dir config creater */
merge_session_cookie_dir_config, /* dir merger --- default is to
* override */
NULL, /* server config */
NULL, /* merge server config */
session_cookie_cmds, /* command apr_table_t */
register_hooks /* register hooks */
};