Line 0
Link Here
|
|
|
1 |
diff --git a/src/crowd_client.c b/src/crowd_client.c |
2 |
index c190d0b..9a42acf 100644 |
3 |
--- a/src/crowd_client.c |
4 |
+++ src/crowd_client.c |
5 |
@@ -631,9 +631,15 @@ static char *make_app_cache_key(const request_rec *r, const crowd_config *config |
6 |
} |
7 |
|
8 |
static char *make_session_cache_key(const char *token, const char *forwarded_for, const request_rec *r, const crowd_config *config) { |
9 |
+#if AP_MODULE_MAGIC_AT_LEAST(20080403,1) |
10 |
+ return log_ralloc(r, apr_psprintf(r->pool, "%s\037%s\037%s\037%s\037%s", token, |
11 |
+ forwarded_for == NULL ? "" : forwarded_for, r->connection->client_ip, config->crowd_app_name, |
12 |
+ config->crowd_url)); |
13 |
+#else |
14 |
return log_ralloc(r, apr_psprintf(r->pool, "%s\037%s\037%s\037%s\037%s", token, |
15 |
forwarded_for == NULL ? "" : forwarded_for, r->connection->remote_ip, config->crowd_app_name, |
16 |
config->crowd_url)); |
17 |
+#endif |
18 |
} |
19 |
|
20 |
/*========================== |
21 |
@@ -764,9 +770,15 @@ static bool handle_crowd_create_session_session_element(write_data_t *write_data |
22 |
} |
23 |
|
24 |
static const char *get_validation_factors(const request_rec *r, const char *forwarded_for) { |
25 |
+#if AP_MODULE_MAGIC_AT_LEAST(20080403,1) |
26 |
+ const char *payload_beginning = log_ralloc(r, apr_pstrcat(r->pool, |
27 |
+ "<validation-factors><validation-factor><name>remote_address</name><value>", r->connection->client_ip, |
28 |
+ "</value></validation-factor>", NULL)); |
29 |
+#else |
30 |
const char *payload_beginning = log_ralloc(r, apr_pstrcat(r->pool, |
31 |
"<validation-factors><validation-factor><name>remote_address</name><value>", r->connection->remote_ip, |
32 |
"</value></validation-factor>", NULL)); |
33 |
+#endif |
34 |
if (payload_beginning == NULL) { |
35 |
return NULL; |
36 |
} |
37 |
@@ -863,7 +875,7 @@ static const char *make_validate_session_url(const request_rec *r, const crowd_c |
38 |
|
39 |
char *url = log_ralloc(r, apr_pstrcat(r->pool, urlWithoutToken, escapedToken, NULL)); |
40 |
|
41 |
- curl_free(escapedToken); |
42 |
+ curl_free((void *)escapedToken); |
43 |
|
44 |
return url; |
45 |
} |
46 |
diff --git a/src/mod_authnz_crowd.c b/src/mod_authnz_crowd.c |
47 |
index 44232a2..e9f849b 100644 |
48 |
--- a/src/mod_authnz_crowd.c |
49 |
+++ src/mod_authnz_crowd.c |
50 |
@@ -520,7 +520,6 @@ static authn_status authn_crowd_check_password(request_rec *r, const char *user, |
51 |
static const authn_provider authn_crowd_provider = |
52 |
{ |
53 |
&authn_crowd_check_password, /* Callback for HTTP Basic authentication */ |
54 |
- NULL /* Callback for HTTP Digest authentication */ |
55 |
}; |
56 |
|
57 |
static unsigned int parse_number(const char *string, const char *name, unsigned int min, unsigned int max, |
58 |
@@ -611,6 +610,83 @@ apr_array_header_t *authnz_crowd_user_groups(const char *username, request_rec * |
59 |
* @param r the current request |
60 |
* @return OK, DECLINED, or HTTP_... |
61 |
*/ |
62 |
+#if AP_MODULE_MAGIC_AT_LEAST(20080403,1) |
63 |
+static authz_status auth_group_checker(request_rec *r, |
64 |
+ const char *require_line, |
65 |
+ const void *parsed_require_args) { |
66 |
+ const char *t, *w; |
67 |
+ ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "mod_authnz_crowd:auth_group_checker"); |
68 |
+ |
69 |
+ authnz_crowd_dir_config *config = get_config(r); |
70 |
+ if (config == NULL) { |
71 |
+ return AUTHZ_GENERAL_ERROR; |
72 |
+ } |
73 |
+ |
74 |
+ if (r->user == NULL) { |
75 |
+ ap_log_rerror(APLOG_MARK, APLOG_CRIT, 0, r, "Authorisation requested, but no user provided."); |
76 |
+ return AUTHZ_DENIED_NO_USER; |
77 |
+ } |
78 |
+ |
79 |
+ apr_array_header_t *user_groups = NULL; |
80 |
+ |
81 |
+ /* Fetch groups only if actually needed. */ |
82 |
+ if (user_groups == NULL) { |
83 |
+ user_groups = crowd_user_groups(r->user, r, config->crowd_config); |
84 |
+ if (user_groups == NULL) { |
85 |
+ return AUTHZ_GENERAL_ERROR; |
86 |
+ } |
87 |
+ } |
88 |
+ |
89 |
+ /* Iterate over the groups mentioned in the requirement. */ |
90 |
+ t = require_line; |
91 |
+ while ((w = ap_getword_conf(r->pool, &t)) && w[0]) { |
92 |
+ int y; |
93 |
+ for (y = 0; y < user_groups->nelts; y++) { |
94 |
+ const char *user_group = APR_ARRAY_IDX(user_groups, y, const char *); |
95 |
+ ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, |
96 |
+ "auth_group_checker: user_group=%s, required_group=%s", user_group, w); |
97 |
+ if (strcasecmp(user_group, w) == 0) { |
98 |
+ ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r, |
99 |
+ "Granted authorisation to '%s' on the basis of membership of '%s'.", r->user, user_group); |
100 |
+ return AUTHZ_GRANTED; |
101 |
+ } |
102 |
+ } |
103 |
+ |
104 |
+ } |
105 |
+ |
106 |
+ |
107 |
+ ap_log_rerror(APLOG_MARK, APLOG_NOTICE, 0, r, "Denied authorisation to '%s'.", r->user); |
108 |
+ return AUTHZ_DENIED; |
109 |
+} |
110 |
+ |
111 |
+static const authz_provider authz_crowd_group_provider = |
112 |
+{ |
113 |
+ &auth_group_checker, |
114 |
+ NULL, |
115 |
+}; |
116 |
+ |
117 |
+static void register_hooks(apr_pool_t *p) |
118 |
+{ |
119 |
+ ap_hook_post_config(post_config, NULL, NULL, APR_HOOK_MIDDLE); |
120 |
+ ap_hook_check_user_id(check_user_id, NULL, NULL, APR_HOOK_FIRST); |
121 |
+ ap_register_auth_provider( |
122 |
+ p, |
123 |
+ AUTHN_PROVIDER_GROUP, |
124 |
+ "crowd", |
125 |
+ AUTHN_PROVIDER_VERSION, |
126 |
+ &authn_crowd_provider, AP_AUTH_INTERNAL_PER_CONF |
127 |
+ ); |
128 |
+ |
129 |
+ // Require crowd-group group1 group2 ... |
130 |
+ ap_register_auth_provider( |
131 |
+ p, |
132 |
+ AUTHZ_PROVIDER_GROUP, |
133 |
+ "crowd-group", |
134 |
+ AUTHZ_PROVIDER_VERSION, |
135 |
+ &authz_crowd_group_provider, AP_AUTH_INTERNAL_PER_CONF |
136 |
+ ); |
137 |
+} |
138 |
+#else |
139 |
static int auth_checker(request_rec *r) { |
140 |
ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "mod_authnz_crowd:auth_checker"); |
141 |
|
142 |
@@ -690,6 +766,9 @@ static void register_hooks(apr_pool_t *p) |
143 |
ap_hook_auth_checker(auth_checker, pre_auth_checker, NULL, APR_HOOK_MIDDLE); |
144 |
} |
145 |
|
146 |
+#endif |
147 |
+ |
148 |
+ |
149 |
module AP_MODULE_DECLARE_DATA authnz_crowd_module = |
150 |
{ |
151 |
STANDARD20_MODULE_STUFF, |
152 |
diff --git a/src/svn/mod_authz_svn_crowd.c b/src/svn/mod_authz_svn_crowd.c |
153 |
index 69b9aa0..3164a40 100644 |
154 |
--- a/src/svn/mod_authz_svn_crowd.c |
155 |
+++ src/svn/mod_authz_svn_crowd.c |
156 |
@@ -50,6 +50,7 @@ |
157 |
|
158 |
#include <svn_pools.h> |
159 |
#include <svn_dirent_uri.h> |
160 |
+#include <svn_version.h> |
161 |
|
162 |
const char * |
163 |
svn_fspath__canonicalize(const char *fspath, |
164 |
@@ -73,6 +74,7 @@ typedef struct authz_svn_config_rec { |
165 |
const char *base_path; |
166 |
const char *access_file; |
167 |
const char *repo_relative_access_file; |
168 |
+ const char *groups_file; // rwb |
169 |
const char *force_username_case; |
170 |
} authz_svn_config_rec; |
171 |
|
172 |
@@ -105,6 +107,12 @@ struct svn_config_t |
173 |
/* Temporary value used for expanded default values in svn_config_get. |
174 |
(Using a stringbuf so that frequent resetting is efficient.) */ |
175 |
svn_stringbuf_t *tmp_value; |
176 |
+ |
177 |
+#if SVN_VER_MINOR >= 7 |
178 |
+ /* Specifies whether section names are populated case sensitively. */ |
179 |
+ svn_boolean_t section_names_case_sensitive; |
180 |
+#endif |
181 |
+ |
182 |
}; |
183 |
|
184 |
typedef struct |
185 |
@@ -113,7 +121,7 @@ typedef struct |
186 |
const char *name; |
187 |
|
188 |
/* The section name, converted into a hash key. */ |
189 |
- const char *hash_key; |
190 |
+ // const char *hash_key; |
191 |
|
192 |
/* Table of cfg_option_t's. */ |
193 |
apr_hash_t *options; |