Blame include/mod_auth.h

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
/**
Packit 90a5c9
 * @file  mod_auth.h
Packit 90a5c9
 * @brief Authentication and Authorization Extension for Apache
Packit 90a5c9
 *
Packit 90a5c9
 * @defgroup MOD_AUTH mod_auth
Packit 90a5c9
 * @ingroup  APACHE_MODS
Packit 90a5c9
 */
Packit 90a5c9
Packit 90a5c9
#ifndef APACHE_MOD_AUTH_H
Packit 90a5c9
#define APACHE_MOD_AUTH_H
Packit 90a5c9
Packit 90a5c9
#include "apr_pools.h"
Packit 90a5c9
#include "apr_hash.h"
Packit 90a5c9
#include "apr_optional.h"
Packit 90a5c9
Packit 90a5c9
#include "httpd.h"
Packit 90a5c9
#include "http_config.h"
Packit 90a5c9
Packit 90a5c9
#ifdef __cplusplus
Packit 90a5c9
extern "C" {
Packit 90a5c9
#endif
Packit 90a5c9
Packit 90a5c9
#define AUTHN_PROVIDER_GROUP "authn"
Packit 90a5c9
#define AUTHZ_PROVIDER_GROUP "authz"
Packit 90a5c9
#define AUTHN_PROVIDER_VERSION "0"
Packit 90a5c9
#define AUTHZ_PROVIDER_VERSION "0"
Packit 90a5c9
#define AUTHN_DEFAULT_PROVIDER "file"
Packit 90a5c9
Packit 90a5c9
#define AUTHN_PROVIDER_NAME_NOTE "authn_provider_name"
Packit 90a5c9
#define AUTHZ_PROVIDER_NAME_NOTE "authz_provider_name"
Packit 90a5c9
Packit 90a5c9
#define AUTHN_PREFIX "AUTHENTICATE_"
Packit 90a5c9
#define AUTHZ_PREFIX "AUTHORIZE_"
Packit 90a5c9
Packit 90a5c9
/** all of the requirements must be met */
Packit 90a5c9
#ifndef SATISFY_ALL
Packit 90a5c9
#define SATISFY_ALL 0
Packit 90a5c9
#endif
Packit 90a5c9
/**  any of the requirements must be met */
Packit 90a5c9
#ifndef SATISFY_ANY
Packit 90a5c9
#define SATISFY_ANY 1
Packit 90a5c9
#endif
Packit 90a5c9
/** There are no applicable satisfy lines */
Packit 90a5c9
#ifndef SATISFY_NOSPEC
Packit 90a5c9
#define SATISFY_NOSPEC 2
Packit 90a5c9
#endif
Packit 90a5c9
Packit 90a5c9
typedef enum {
Packit 90a5c9
    AUTH_DENIED,
Packit 90a5c9
    AUTH_GRANTED,
Packit 90a5c9
    AUTH_USER_FOUND,
Packit 90a5c9
    AUTH_USER_NOT_FOUND,
Packit 90a5c9
    AUTH_GENERAL_ERROR
Packit 90a5c9
} authn_status;
Packit 90a5c9
Packit 90a5c9
typedef enum {
Packit 90a5c9
    AUTHZ_DENIED,
Packit 90a5c9
    AUTHZ_GRANTED,
Packit 90a5c9
    AUTHZ_NEUTRAL,
Packit 90a5c9
    AUTHZ_GENERAL_ERROR,
Packit 90a5c9
    AUTHZ_DENIED_NO_USER      /* denied because r->user == NULL */
Packit 90a5c9
} authz_status;
Packit 90a5c9
Packit 90a5c9
typedef struct {
Packit 90a5c9
    /* Given a username and password, expected to return AUTH_GRANTED
Packit 90a5c9
     * if we can validate this user/password combination.
Packit 90a5c9
     */
Packit 90a5c9
    authn_status (*check_password)(request_rec *r, const char *user,
Packit 90a5c9
                                   const char *password);
Packit 90a5c9
Packit 90a5c9
    /* Given a user and realm, expected to return AUTH_USER_FOUND if we
Packit 90a5c9
     * can find a md5 hash of 'user:realm:password'
Packit 90a5c9
     */
Packit 90a5c9
    authn_status (*get_realm_hash)(request_rec *r, const char *user,
Packit 90a5c9
                                   const char *realm, char **rethash);
Packit 90a5c9
} authn_provider;
Packit 90a5c9
Packit 90a5c9
/* A linked-list of authn providers. */
Packit 90a5c9
typedef struct authn_provider_list authn_provider_list;
Packit 90a5c9
Packit 90a5c9
struct authn_provider_list {
Packit 90a5c9
    const char *provider_name;
Packit 90a5c9
    const authn_provider *provider;
Packit 90a5c9
    authn_provider_list *next;
Packit 90a5c9
};
Packit 90a5c9
Packit 90a5c9
typedef struct {
Packit 90a5c9
    /* Given a request_rec, expected to return AUTHZ_GRANTED
Packit 90a5c9
     * if we can authorize user access.
Packit 90a5c9
     * @param r the request record
Packit 90a5c9
     * @param require_line the argument to the authz provider
Packit 90a5c9
     * @param parsed_require_line the value set by parse_require_line(), if any
Packit 90a5c9
     */
Packit 90a5c9
    authz_status (*check_authorization)(request_rec *r,
Packit 90a5c9
                                        const char *require_line,
Packit 90a5c9
                                        const void *parsed_require_line);
Packit 90a5c9
Packit 90a5c9
    /** Check the syntax of a require line and optionally cache the parsed
Packit 90a5c9
     * line. This function may be NULL.
Packit 90a5c9
     * @param cmd the config directive
Packit 90a5c9
     * @param require_line the argument to the authz provider
Packit 90a5c9
     * @param parsed_require_line place to store parsed require_line for use by provider
Packit 90a5c9
     * @return Error message or NULL on success
Packit 90a5c9
     */
Packit 90a5c9
    const char *(*parse_require_line)(cmd_parms *cmd, const char *require_line,
Packit 90a5c9
                                      const void **parsed_require_line);
Packit 90a5c9
} authz_provider;
Packit 90a5c9
Packit 90a5c9
/* ap_authn_cache_store: Optional function for authn providers
Packit 90a5c9
 * to enable cacheing their lookups with mod_authn_cache
Packit 90a5c9
 * @param r The request rec
Packit 90a5c9
 * @param module Module identifier
Packit 90a5c9
 * @param user User name to authenticate
Packit 90a5c9
 * @param realm Digest authn realm (NULL for basic authn)
Packit 90a5c9
 * @param data The value looked up by the authn provider, to cache
Packit 90a5c9
 */
Packit 90a5c9
APR_DECLARE_OPTIONAL_FN(void, ap_authn_cache_store,
Packit 90a5c9
                        (request_rec*, const char*, const char*,
Packit 90a5c9
                         const char*, const char*));
Packit 90a5c9
Packit 90a5c9
#ifdef __cplusplus
Packit 90a5c9
}
Packit 90a5c9
#endif
Packit 90a5c9
Packit 90a5c9
#endif