Mercurial > hg
comparison tests/test-hgweb-auth.py.out @ 15005:4a43e23b8c55 stable 1.9.1
hgweb: do not ignore [auth] if url has a username (issue2822)
The [auth] section was ignored when handling URLs like:
http://user@example.com/foo
Instead, we look in [auth] for an entry matching the URL and supplied user
name. Entries without username can match URL with a username. Prefix length
ties are resolved in favor of entries matching the username. With:
foo.prefix = http://example.org
foo.username = user
foo.password = password
bar.prefix = http://example.org/bar
and the input URL:
http://user@example.org/bar
the 'bar' entry will be selected because of prefix length, therefore prompting
for a password. This behaviour ensure that entries selection is consistent when
looking for credentials or for certificates, and that certificates can be
picked even if their entries do no define usernames while the URL does.
Additionally, entries without a username matched against a username are
returned as if they did have requested username set to avoid prompting again
for a username if the password is not set.
v2: reparse the URL in readauthforuri() to handle HTTP and HTTPS similarly.
v3: allow unset usernames to match URL usernames to pick certificates. Resolve
prefix length ties in favor of entries with usernames.
author | Patrick Mezard <pmezard@gmail.com> |
---|---|
date | Mon, 01 Aug 2011 23:58:50 +0200 |
parents | 89c80c3dc584 |
children | 0f1311e829c9 |
comparison
equal
deleted
inserted
replaced
15004:d06b9c55ddab | 15005:4a43e23b8c55 |
---|---|
12 abort | 12 abort |
13 URI: https://example.org/foo/bar | 13 URI: https://example.org/foo/bar |
14 abort | 14 abort |
15 URI: https://example.org/bar | 15 URI: https://example.org/bar |
16 abort | 16 abort |
17 URI: https://x@example.org/bar | |
18 abort | |
19 URI: https://y@example.org/bar | |
20 abort | |
17 CFG: {x.prefix: https://example.org} | 21 CFG: {x.prefix: https://example.org} |
18 URI: http://example.org/foo | 22 URI: http://example.org/foo |
19 abort | 23 abort |
20 URI: http://example.org/foo/bar | 24 URI: http://example.org/foo/bar |
21 abort | 25 abort |
25 ('x', 'x') | 29 ('x', 'x') |
26 URI: https://example.org/foo/bar | 30 URI: https://example.org/foo/bar |
27 ('x', 'x') | 31 ('x', 'x') |
28 URI: https://example.org/bar | 32 URI: https://example.org/bar |
29 ('x', 'x') | 33 ('x', 'x') |
34 URI: https://x@example.org/bar | |
35 ('x', 'x') | |
36 URI: https://y@example.org/bar | |
37 abort | |
30 CFG: {x.prefix: http://example.org, x.schemes: https} | 38 CFG: {x.prefix: http://example.org, x.schemes: https} |
31 URI: http://example.org/foo | 39 URI: http://example.org/foo |
32 ('x', 'x') | 40 ('x', 'x') |
33 URI: http://example.org/foo/bar | 41 URI: http://example.org/foo/bar |
34 ('x', 'x') | 42 ('x', 'x') |
37 URI: https://example.org/foo | 45 URI: https://example.org/foo |
38 abort | 46 abort |
39 URI: https://example.org/foo/bar | 47 URI: https://example.org/foo/bar |
40 abort | 48 abort |
41 URI: https://example.org/bar | 49 URI: https://example.org/bar |
50 abort | |
51 URI: https://x@example.org/bar | |
52 abort | |
53 URI: https://y@example.org/bar | |
42 abort | 54 abort |
43 CFG: {x.prefix: https://example.org, x.schemes: http} | 55 CFG: {x.prefix: https://example.org, x.schemes: http} |
44 URI: http://example.org/foo | 56 URI: http://example.org/foo |
45 abort | 57 abort |
46 URI: http://example.org/foo/bar | 58 URI: http://example.org/foo/bar |
51 ('x', 'x') | 63 ('x', 'x') |
52 URI: https://example.org/foo/bar | 64 URI: https://example.org/foo/bar |
53 ('x', 'x') | 65 ('x', 'x') |
54 URI: https://example.org/bar | 66 URI: https://example.org/bar |
55 ('x', 'x') | 67 ('x', 'x') |
68 URI: https://x@example.org/bar | |
69 ('x', 'x') | |
70 URI: https://y@example.org/bar | |
71 abort | |
56 | 72 |
57 *** Test separately configured schemes | 73 *** Test separately configured schemes |
58 | 74 |
59 CFG: {x.prefix: example.org, x.schemes: http} | 75 CFG: {x.prefix: example.org, x.schemes: http} |
60 URI: http://example.org/foo | 76 URI: http://example.org/foo |
67 abort | 83 abort |
68 URI: https://example.org/foo/bar | 84 URI: https://example.org/foo/bar |
69 abort | 85 abort |
70 URI: https://example.org/bar | 86 URI: https://example.org/bar |
71 abort | 87 abort |
88 URI: https://x@example.org/bar | |
89 abort | |
90 URI: https://y@example.org/bar | |
91 abort | |
72 CFG: {x.prefix: example.org, x.schemes: https} | 92 CFG: {x.prefix: example.org, x.schemes: https} |
73 URI: http://example.org/foo | 93 URI: http://example.org/foo |
74 abort | 94 abort |
75 URI: http://example.org/foo/bar | 95 URI: http://example.org/foo/bar |
76 abort | 96 abort |
80 ('x', 'x') | 100 ('x', 'x') |
81 URI: https://example.org/foo/bar | 101 URI: https://example.org/foo/bar |
82 ('x', 'x') | 102 ('x', 'x') |
83 URI: https://example.org/bar | 103 URI: https://example.org/bar |
84 ('x', 'x') | 104 ('x', 'x') |
105 URI: https://x@example.org/bar | |
106 ('x', 'x') | |
107 URI: https://y@example.org/bar | |
108 abort | |
85 CFG: {x.prefix: example.org, x.schemes: http https} | 109 CFG: {x.prefix: example.org, x.schemes: http https} |
86 URI: http://example.org/foo | 110 URI: http://example.org/foo |
87 ('x', 'x') | 111 ('x', 'x') |
88 URI: http://example.org/foo/bar | 112 URI: http://example.org/foo/bar |
89 ('x', 'x') | 113 ('x', 'x') |
93 ('x', 'x') | 117 ('x', 'x') |
94 URI: https://example.org/foo/bar | 118 URI: https://example.org/foo/bar |
95 ('x', 'x') | 119 ('x', 'x') |
96 URI: https://example.org/bar | 120 URI: https://example.org/bar |
97 ('x', 'x') | 121 ('x', 'x') |
122 URI: https://x@example.org/bar | |
123 ('x', 'x') | |
124 URI: https://y@example.org/bar | |
125 abort | |
98 | 126 |
99 *** Test prefix matching | 127 *** Test prefix matching |
100 | 128 |
101 CFG: {x.prefix: http://example.org/foo, y.prefix: http://example.org/bar} | 129 CFG: {x.prefix: http://example.org/foo, y.prefix: http://example.org/bar} |
102 URI: http://example.org/foo | 130 URI: http://example.org/foo |
109 abort | 137 abort |
110 URI: https://example.org/foo/bar | 138 URI: https://example.org/foo/bar |
111 abort | 139 abort |
112 URI: https://example.org/bar | 140 URI: https://example.org/bar |
113 abort | 141 abort |
142 URI: https://x@example.org/bar | |
143 abort | |
144 URI: https://y@example.org/bar | |
145 abort | |
114 CFG: {x.prefix: http://example.org/foo, y.prefix: http://example.org/foo/bar} | 146 CFG: {x.prefix: http://example.org/foo, y.prefix: http://example.org/foo/bar} |
115 URI: http://example.org/foo | 147 URI: http://example.org/foo |
116 ('x', 'x') | 148 ('x', 'x') |
117 URI: http://example.org/foo/bar | 149 URI: http://example.org/foo/bar |
118 ('y', 'y') | 150 ('y', 'y') |
121 URI: https://example.org/foo | 153 URI: https://example.org/foo |
122 abort | 154 abort |
123 URI: https://example.org/foo/bar | 155 URI: https://example.org/foo/bar |
124 abort | 156 abort |
125 URI: https://example.org/bar | 157 URI: https://example.org/bar |
158 abort | |
159 URI: https://x@example.org/bar | |
160 abort | |
161 URI: https://y@example.org/bar | |
126 abort | 162 abort |
127 CFG: {x.prefix: *, y.prefix: https://example.org/bar} | 163 CFG: {x.prefix: *, y.prefix: https://example.org/bar} |
128 URI: http://example.org/foo | 164 URI: http://example.org/foo |
129 abort | 165 abort |
130 URI: http://example.org/foo/bar | 166 URI: http://example.org/foo/bar |
135 ('x', 'x') | 171 ('x', 'x') |
136 URI: https://example.org/foo/bar | 172 URI: https://example.org/foo/bar |
137 ('x', 'x') | 173 ('x', 'x') |
138 URI: https://example.org/bar | 174 URI: https://example.org/bar |
139 ('y', 'y') | 175 ('y', 'y') |
176 URI: https://x@example.org/bar | |
177 ('x', 'x') | |
178 URI: https://y@example.org/bar | |
179 ('y', 'y') | |
180 | |
181 *** Test user matching | |
182 | |
183 CFG: {x.password: xpassword, x.prefix: http://example.org/foo, x.username: None} | |
184 URI: http://y@example.org/foo | |
185 ('y', 'xpassword') | |
186 CFG: {x.password: xpassword, x.prefix: http://example.org/foo, x.username: None, y.password: ypassword, y.prefix: http://example.org/foo, y.username: y} | |
187 URI: http://y@example.org/foo | |
188 ('y', 'ypassword') | |
189 CFG: {x.password: xpassword, x.prefix: http://example.org/foo/bar, x.username: None, y.password: ypassword, y.prefix: http://example.org/foo, y.username: y} | |
190 URI: http://y@example.org/foo/bar | |
191 ('y', 'xpassword') |