auth.h 1.42 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
/* Icecast
 *
 * This program is distributed under the GNU General Public License, version 2.
 * A copy of this license is included with this source.
 *
 * Copyright 2000-2004, Jack Moffitt <jack@xiph.org, 
 *                      Michael Smith <msmith@xiph.org>,
 *                      oddsock <oddsock@xiph.org>,
 *                      Karl Heyes <karl@xiph.org>
 *                      and others (see AUTHORS for details).
 */

Michael Smith's avatar
Michael Smith committed
13
14
15
#ifndef __AUTH_H__
#define __AUTH_H__

Karl Heyes's avatar
Karl Heyes committed
16
17
18
19
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

20
21
22
#include <libxml/xmlmemory.h>
#include <libxml/parser.h>
#include <libxml/tree.h>
Karl Heyes's avatar
Karl Heyes committed
23
24
#include "source.h"
#include "client.h"
Michael Smith's avatar
Michael Smith committed
25
26
27
28
29

typedef enum
{
    AUTH_OK,
    AUTH_FAILED,
30
    AUTH_FORBIDDEN,
31
32
33
    AUTH_USERADDED,
    AUTH_USEREXISTS,
    AUTH_USERDELETED,
Michael Smith's avatar
Michael Smith committed
34
35
36
37
38
39
} auth_result;

typedef struct auth_tag
{
    /* Authenticate using the given username and password */
    auth_result (*authenticate)(struct auth_tag *self, 
40
            source_t *source, char *username, char *password);
Michael Smith's avatar
Michael Smith committed
41
42
    void (*free)(struct auth_tag *self);
    void *state;
43
    char *type;
Michael Smith's avatar
Michael Smith committed
44
45
46
47
48
49
} auth_t;

auth_result auth_check_client(source_t *source, client_t *client);

auth_t *auth_get_authenticator(char *type, config_options_t *options);
void *auth_clear(auth_t *authenticator);
50
51
52
int auth_get_userlist(source_t *source, xmlNodePtr srcnode);
int auth_adduser(source_t *source, char *username, char *password);
int auth_deleteuser(source_t *source, char *username);
Michael Smith's avatar
Michael Smith committed
53
54
55
56

#endif