|
Packit |
90a5c9 |
/* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
Packit |
90a5c9 |
* contributor license agreements. See the NOTICE file distributed with
|
|
Packit |
90a5c9 |
* this work for additional information regarding copyright ownership.
|
|
Packit |
90a5c9 |
* The ASF licenses this file to You under the Apache License, Version 2.0
|
|
Packit |
90a5c9 |
* (the "License"); you may not use this file except in compliance with
|
|
Packit |
90a5c9 |
* the License. You may obtain a copy of the License at
|
|
Packit |
90a5c9 |
*
|
|
Packit |
90a5c9 |
* http://www.apache.org/licenses/LICENSE-2.0
|
|
Packit |
90a5c9 |
*
|
|
Packit |
90a5c9 |
* Unless required by applicable law or agreed to in writing, software
|
|
Packit |
90a5c9 |
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
Packit |
90a5c9 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
Packit |
90a5c9 |
* See the License for the specific language governing permissions and
|
|
Packit |
90a5c9 |
* limitations under the License.
|
|
Packit |
90a5c9 |
*/
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
#ifndef MOD_SESSION_H
|
|
Packit |
90a5c9 |
#define MOD_SESSION_H
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
/* Create a set of SESSION_DECLARE(type), SESSION_DECLARE_NONSTD(type) and
|
|
Packit |
90a5c9 |
* SESSION_DECLARE_DATA with appropriate export and import tags for the platform
|
|
Packit |
90a5c9 |
*/
|
|
Packit |
90a5c9 |
#if !defined(WIN32)
|
|
Packit |
90a5c9 |
#define SESSION_DECLARE(type) type
|
|
Packit |
90a5c9 |
#define SESSION_DECLARE_NONSTD(type) type
|
|
Packit |
90a5c9 |
#define SESSION_DECLARE_DATA
|
|
Packit |
90a5c9 |
#elif defined(SESSION_DECLARE_STATIC)
|
|
Packit |
90a5c9 |
#define SESSION_DECLARE(type) type __stdcall
|
|
Packit |
90a5c9 |
#define SESSION_DECLARE_NONSTD(type) type
|
|
Packit |
90a5c9 |
#define SESSION_DECLARE_DATA
|
|
Packit |
90a5c9 |
#elif defined(SESSION_DECLARE_EXPORT)
|
|
Packit |
90a5c9 |
#define SESSION_DECLARE(type) __declspec(dllexport) type __stdcall
|
|
Packit |
90a5c9 |
#define SESSION_DECLARE_NONSTD(type) __declspec(dllexport) type
|
|
Packit |
90a5c9 |
#define SESSION_DECLARE_DATA __declspec(dllexport)
|
|
Packit |
90a5c9 |
#else
|
|
Packit |
90a5c9 |
#define SESSION_DECLARE(type) __declspec(dllimport) type __stdcall
|
|
Packit |
90a5c9 |
#define SESSION_DECLARE_NONSTD(type) __declspec(dllimport) type
|
|
Packit |
90a5c9 |
#define SESSION_DECLARE_DATA __declspec(dllimport)
|
|
Packit |
90a5c9 |
#endif
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
/**
|
|
Packit |
90a5c9 |
* @file mod_session.h
|
|
Packit |
90a5c9 |
* @brief Session Module for Apache
|
|
Packit |
90a5c9 |
*
|
|
Packit |
90a5c9 |
* @defgroup MOD_SESSION mod_session
|
|
Packit |
90a5c9 |
* @ingroup APACHE_MODS
|
|
Packit |
90a5c9 |
* @{
|
|
Packit |
90a5c9 |
*/
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
#include "apr_hooks.h"
|
|
Packit |
90a5c9 |
#include "apr_optional.h"
|
|
Packit |
90a5c9 |
#include "apr_tables.h"
|
|
Packit |
90a5c9 |
#include "apr_uuid.h"
|
|
Packit |
90a5c9 |
#include "apr_pools.h"
|
|
Packit |
90a5c9 |
#include "apr_time.h"
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
#include "httpd.h"
|
|
Packit |
90a5c9 |
#include "http_config.h"
|
|
Packit |
90a5c9 |
#include "ap_config.h"
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
#define MOD_SESSION_NOTES_KEY "mod_session_key"
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
/**
|
|
Packit |
90a5c9 |
* Define the name of a username stored in the session, so that modules interested
|
|
Packit |
90a5c9 |
* in the username can find it in a standard place.
|
|
Packit |
90a5c9 |
*/
|
|
Packit |
90a5c9 |
#define MOD_SESSION_USER "user"
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
/**
|
|
Packit |
90a5c9 |
* Define the name of a password stored in the session, so that modules interested
|
|
Packit |
90a5c9 |
* in the password can find it in a standard place.
|
|
Packit |
90a5c9 |
*/
|
|
Packit |
90a5c9 |
#define MOD_SESSION_PW "pw"
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
/**
|
|
Packit |
90a5c9 |
* A session structure.
|
|
Packit |
90a5c9 |
*
|
|
Packit |
90a5c9 |
* At the core of the session is a set of name value pairs making up the
|
|
Packit |
90a5c9 |
* session.
|
|
Packit |
90a5c9 |
*
|
|
Packit |
90a5c9 |
* The session might be uniquely identified by an anonymous uuid, or
|
|
Packit |
90a5c9 |
* a remote_user value, or both.
|
|
Packit |
90a5c9 |
*/
|
|
Packit |
90a5c9 |
typedef struct {
|
|
Packit |
90a5c9 |
apr_pool_t *pool; /* pool to be used for this session */
|
|
Packit |
90a5c9 |
apr_uuid_t *uuid; /* anonymous uuid of this particular session */
|
|
Packit |
90a5c9 |
const char *remote_user; /* user who owns this particular session */
|
|
Packit |
90a5c9 |
apr_table_t *entries; /* key value pairs */
|
|
Packit |
90a5c9 |
const char *encoded; /* the encoded version of the key value pairs */
|
|
Packit |
90a5c9 |
apr_time_t expiry; /* if > 0, the time of expiry of this session */
|
|
Packit |
90a5c9 |
long maxage; /* if > 0, the maxage of the session, from
|
|
Packit |
90a5c9 |
* which expiry is calculated */
|
|
Packit |
90a5c9 |
int dirty; /* dirty flag */
|
|
Packit |
90a5c9 |
int cached; /* true if this session was loaded from a
|
|
Packit |
90a5c9 |
* cache of some kind */
|
|
Packit |
90a5c9 |
int written; /* true if this session has already been
|
|
Packit |
90a5c9 |
* written */
|
|
Packit |
90a5c9 |
} session_rec;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
/**
|
|
Packit |
90a5c9 |
* Structure to carry the per-dir session config.
|
|
Packit |
90a5c9 |
*/
|
|
Packit |
90a5c9 |
typedef struct {
|
|
Packit |
90a5c9 |
int enabled; /* whether the session has been enabled for
|
|
Packit |
90a5c9 |
* this directory */
|
|
Packit |
90a5c9 |
int enabled_set;
|
|
Packit |
90a5c9 |
long maxage; /* seconds until session expiry */
|
|
Packit |
90a5c9 |
int maxage_set;
|
|
Packit |
90a5c9 |
const char *header; /* header to inject session */
|
|
Packit |
90a5c9 |
int header_set;
|
|
Packit |
90a5c9 |
int env; /* whether the session has been enabled for
|
|
Packit |
90a5c9 |
* this directory */
|
|
Packit |
90a5c9 |
int env_set;
|
|
Packit |
90a5c9 |
apr_array_header_t *includes; /* URL prefixes to be included. All
|
|
Packit |
90a5c9 |
* URLs included if empty */
|
|
Packit |
90a5c9 |
apr_array_header_t *excludes; /* URL prefixes to be excluded. No
|
|
Packit |
90a5c9 |
* URLs excluded if empty */
|
|
Packit |
682164 |
apr_time_t expiry_update_time; /* seconds the session expiry may change and
|
|
Packit |
682164 |
* not have to be rewritten */
|
|
Packit |
682164 |
int expiry_update_set;
|
|
Packit |
90a5c9 |
} session_dir_conf;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
/**
|
|
Packit |
90a5c9 |
* Hook to load the session.
|
|
Packit |
90a5c9 |
*
|
|
Packit |
90a5c9 |
* If the session doesn't exist, a blank one will be created.
|
|
Packit |
90a5c9 |
*
|
|
Packit |
90a5c9 |
* @param r The request
|
|
Packit |
90a5c9 |
* @param z A pointer to where the session will be written.
|
|
Packit |
90a5c9 |
*/
|
|
Packit |
90a5c9 |
APR_DECLARE_EXTERNAL_HOOK(ap, SESSION, apr_status_t, session_load,
|
|
Packit |
90a5c9 |
(request_rec * r, session_rec ** z))
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
/**
|
|
Packit |
90a5c9 |
* Hook to save the session.
|
|
Packit |
90a5c9 |
*
|
|
Packit |
90a5c9 |
* In most implementations the session is only saved if the dirty flag is
|
|
Packit |
90a5c9 |
* true. This prevents the session being saved unnecessarily.
|
|
Packit |
90a5c9 |
*
|
|
Packit |
90a5c9 |
* @param r The request
|
|
Packit |
90a5c9 |
* @param z A pointer to where the session will be written.
|
|
Packit |
90a5c9 |
*/
|
|
Packit |
90a5c9 |
APR_DECLARE_EXTERNAL_HOOK(ap, SESSION, apr_status_t, session_save,
|
|
Packit |
90a5c9 |
(request_rec * r, session_rec * z))
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
/**
|
|
Packit |
90a5c9 |
* Hook to encode the session.
|
|
Packit |
90a5c9 |
*
|
|
Packit |
90a5c9 |
* In the default implementation, the key value pairs are encoded using
|
|
Packit |
90a5c9 |
* key value pairs separated by equals, in turn separated by ampersand,
|
|
Packit |
90a5c9 |
* like a web form.
|
|
Packit |
90a5c9 |
*
|
|
Packit |
90a5c9 |
* @param r The request
|
|
Packit |
90a5c9 |
* @param z A pointer to where the session will be written.
|
|
Packit |
90a5c9 |
*/
|
|
Packit |
90a5c9 |
APR_DECLARE_EXTERNAL_HOOK(ap, SESSION, apr_status_t, session_encode,
|
|
Packit |
90a5c9 |
(request_rec * r, session_rec * z))
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
/**
|
|
Packit |
90a5c9 |
* Hook to decode the session.
|
|
Packit |
90a5c9 |
*
|
|
Packit |
90a5c9 |
* In the default implementation, the key value pairs are encoded using
|
|
Packit |
90a5c9 |
* key value pairs separated by equals, in turn separated by ampersand,
|
|
Packit |
90a5c9 |
* like a web form.
|
|
Packit |
90a5c9 |
*
|
|
Packit |
90a5c9 |
* @param r The request
|
|
Packit |
90a5c9 |
* @param z A pointer to where the session will be written.
|
|
Packit |
90a5c9 |
*/
|
|
Packit |
90a5c9 |
APR_DECLARE_EXTERNAL_HOOK(ap, SESSION, apr_status_t, session_decode,
|
|
Packit |
90a5c9 |
(request_rec * r, session_rec * z))
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
APR_DECLARE_OPTIONAL_FN(
|
|
Packit |
90a5c9 |
apr_status_t,
|
|
Packit |
90a5c9 |
ap_session_get,
|
|
Packit |
90a5c9 |
(request_rec * r, session_rec * z, const char *key, const char **value));
|
|
Packit |
90a5c9 |
APR_DECLARE_OPTIONAL_FN(apr_status_t, ap_session_set,
|
|
Packit |
90a5c9 |
(request_rec * r, session_rec * z, const char *key, const char *value));
|
|
Packit |
90a5c9 |
APR_DECLARE_OPTIONAL_FN(apr_status_t, ap_session_load,
|
|
Packit |
90a5c9 |
(request_rec *, session_rec **));
|
|
Packit |
90a5c9 |
APR_DECLARE_OPTIONAL_FN(apr_status_t, ap_session_save,
|
|
Packit |
90a5c9 |
(request_rec *, session_rec *));
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
/**
|
|
Packit |
90a5c9 |
* The name of the module.
|
|
Packit |
90a5c9 |
*/
|
|
Packit |
90a5c9 |
extern module AP_MODULE_DECLARE_DATA session_module;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
#endif /* MOD_SESSION_H */
|
|
Packit |
90a5c9 |
/** @} */
|