summaryrefslogtreecommitdiff
path: root/libsoup/soup-server-auth.h
blob: b53f054cdbdcd0d087036a6b8dd504cf989b8912 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
 * soup-server-auth.h: Server-side authentication handling
 *
 * Authors:
 *      Alex Graveley (alex@ximian.com)
 *
 * Copyright (C) 2001-2002, Ximian, Inc.
 */

#ifndef SOUP_SERVER_AUTH_H
#define SOUP_SERVER_AUTH_H 1

#include <glib.h>
#include <libsoup/soup-message.h>
#include <libsoup/soup-auth.h>

typedef union _SoupServerAuth SoupServerAuth;
typedef struct _SoupServerAuthContext SoupServerAuthContext;

typedef gboolean (*SoupServerAuthCallbackFn) (SoupServerAuthContext *auth_ctx,
					      SoupServerAuth        *auth,
					      SoupMessage           *msg, 
					      gpointer               data);

struct _SoupServerAuthContext {
	guint                     types;
	SoupServerAuthCallbackFn  callback;
	gpointer                  user_data;

	struct {
		const gchar *realm;
	} basic_info;

	struct {
		const gchar *realm;
		guint        allow_algorithms;
		gboolean     force_integrity;
	} digest_info;
};

void soup_server_auth_context_challenge (SoupServerAuthContext *auth_ctx,
					 SoupMessage           *msg,
					 gchar                 *header_name);


typedef enum {
	SOUP_SERVER_AUTH_BASIC,
	SOUP_SERVER_AUTH_DIGEST
} SoupServerAuthType;

typedef struct {
	SoupServerAuthType  type;
	const char         *user;
	const char         *passwd;
} SoupServerAuthBasic;

typedef enum {
	SOUP_ALGORITHM_MD5      = 1 << 0,
	SOUP_ALGORITHM_MD5_SESS = 1 << 1
} SoupDigestAlgorithm;

typedef struct {
	SoupServerAuthType    type;
	SoupDigestAlgorithm   algorithm;
	gboolean              integrity;
	const gchar          *realm;
	const gchar          *user;
	const gchar          *nonce;
	gint                  nonce_count;
	const gchar          *cnonce;
	const gchar          *digest_uri;
	const gchar          *digest_response;
	const gchar          *request_method;
} SoupServerAuthDigest;

union _SoupServerAuth {
	SoupServerAuthType    type;
	SoupServerAuthBasic   basic;
	SoupServerAuthDigest  digest;
};

SoupServerAuth *soup_server_auth_new          (SoupServerAuthContext *auth_ctx, 
				               const GSList          *auth_hdrs,
					       SoupMessage           *msg);

void            soup_server_auth_free         (SoupServerAuth        *auth);

const gchar    *soup_server_auth_get_user     (SoupServerAuth        *auth);

gboolean        soup_server_auth_check_passwd (SoupServerAuth        *auth,
					       gchar                 *passwd);

#endif /* SOUP_SERVER_AUTH_H */