mod_authz_dbd.c revision 7c2df38555e33d4c30de9973722128cc9646a1b3
/* 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 "httpd.h"
#include "http_log.h"
#include "http_config.h"
#include "ap_provider.h"
#include "http_request.h"
#include "http_protocol.h"
#include "http_core.h"
#include "apr_dbd.h"
#include "mod_dbd.h"
#include "apr_strings.h"
#include "mod_authz_dbd.h"
#include "mod_auth.h"
/* Export a hook for modules that manage clientside sessions
* (e.g. mod_auth_cookie)
*
* XXX: WHY would this be specific to dbd_authz? Why wouldn't we track
* this across all authz user providers in a lower level mod, such as
*/
typedef struct {
const char *query;
const char *redir_query;
int redirect;
} authz_dbd_cfg ;
static const char *const noerror = "???";
{
return ret;
}
{
return ret;
}
const char *query)
{
static unsigned int label_num = 0;
char *label;
if (err)
return err;
if (dbd_prepare == NULL) {
if (dbd_prepare == NULL) {
return "You must load mod_dbd to enable AuthzDBD functions";
}
}
/* save the label here for our own use */
}
static const command_rec authz_dbd_cmds[] = {
"Whether to redirect to referer on successful login"),
"SQL query for DBD Authz or login"),
"SQL query to get per-user redirect URL after login"),
{NULL}
};
const char *action)
{
int rv;
int nrows;
const char *message;
"No query configured for %s!", action);
return HTTP_INTERNAL_SERVER_ERROR;
}
"Error retrieving Query for %s!", action);
return HTTP_INTERNAL_SERVER_ERROR;
}
if (rv == 0) {
if (nrows != 1) {
"authz_dbd: %s of user %s updated %d rows",
}
}
else {
"authz_dbd: query for %s failed; user %s [%s]",
return HTTP_INTERNAL_SERVER_ERROR;
}
}
"authz_dbd: no redirect query!");
/* OK, this is non-critical; we can just not-redirect */
}
rv != -1;
if (rv != 0) {
"authz_dbd in get_row; action=%s user=%s [%s]",
}
}
/* we can't break out here or row won't get cleaned up */
}
}
else {
}
}
r->status = HTTP_MOVED_TEMPORARILY;
}
return OK;
}
{
/* SELECT group FROM authz WHERE user = %s */
int rv;
const char *message;
const char **group;
"No query configured for dbd-group!");
return HTTP_INTERNAL_SERVER_ERROR;
}
"Error retrieving query for dbd-group!");
return HTTP_INTERNAL_SERVER_ERROR;
}
if (rv == 0) {
rv != -1;
if (rv == 0) {
}
else {
"authz_dbd in get_row; group query for user=%s [%s]",
return HTTP_INTERNAL_SERVER_ERROR;
}
}
}
else {
"authz_dbd, in groups query for %s [%s]",
return HTTP_INTERNAL_SERVER_ERROR;
}
return OK;
}
const char *require_args,
const void *parsed_require_args)
{
int i, rv;
const char *w;
const char *t;
if (!r->user) {
return AUTHZ_DENIED_NO_USER;
}
return AUTHZ_GENERAL_ERROR;
}
}
t = require_args;
while (t[0]) {
w = ap_getword_white(r->pool, &t);
return AUTHZ_GRANTED;
}
}
}
return AUTHZ_DENIED;
}
const char *require_args,
const void *parsed_require_args)
{
if (!r->user) {
return AUTHZ_DENIED_NO_USER;
}
}
const char *require_args,
const void *parsed_require_args)
{
if (!r->user) {
return AUTHZ_DENIED_NO_USER;
}
}
static const authz_provider authz_dbdgroup_provider =
{
NULL,
};
static const authz_provider authz_dbdlogin_provider =
{
NULL,
};
static const authz_provider authz_dbdlogout_provider =
{
NULL,
};
static void authz_dbd_hooks(apr_pool_t *p)
{
}
{
NULL,
NULL,
};