Show More
@@ -32,7 +32,9 b' Config::' | |||
|
32 | 32 | curlcmd = curl --connect-timeout 2 --retry 3 --silent |
|
33 | 33 | |
|
34 | 34 | [auth] |
|
35 | example.url = https://phab.example.com/ | |
|
35 | example.schemes = https | |
|
36 | example.prefix = phab.example.com | |
|
37 | ||
|
36 | 38 | # API token. Get it from https://$HOST/conduit/login/ |
|
37 | 39 | example.phabtoken = cli-xxxxxxxxxxxxxxxxxxxxxxxxxxxx |
|
38 | 40 | """ |
@@ -51,6 +53,7 b' from mercurial import (' | |||
|
51 | 53 | context, |
|
52 | 54 | encoding, |
|
53 | 55 | error, |
|
56 | httpconnection as httpconnectionmod, | |
|
54 | 57 | mdiff, |
|
55 | 58 | obsutil, |
|
56 | 59 | parser, |
@@ -135,7 +138,7 b' def readlegacytoken(repo, url):' | |||
|
135 | 138 | def readurltoken(repo): |
|
136 | 139 | """return conduit url, token and make sure they exist |
|
137 | 140 | |
|
138 |
Currently read from [ |
|
|
141 | Currently read from [auth] config section. In the future, it might | |
|
139 | 142 | make sense to read from .arcconfig and .arcrc as well. |
|
140 | 143 | """ |
|
141 | 144 | url = repo.ui.config('phabricator', 'url') |
@@ -143,22 +146,15 b' def readurltoken(repo):' | |||
|
143 | 146 | raise error.Abort(_('config %s.%s is required') |
|
144 | 147 | % ('phabricator', 'url')) |
|
145 | 148 | |
|
146 | groups = {} | |
|
147 | for key, val in repo.ui.configitems('auth'): | |
|
148 | if '.' not in key: | |
|
149 | repo.ui.warn(_("ignoring invalid [auth] key '%s'\n") | |
|
150 | % key) | |
|
151 | continue | |
|
152 | group, setting = key.rsplit('.', 1) | |
|
153 | groups.setdefault(group, {})[setting] = val | |
|
149 | res = httpconnectionmod.readauthforuri(repo.ui, url, util.url(url).user) | |
|
150 | token = None | |
|
154 | 151 | |
|
155 | token = None | |
|
156 | for group, auth in groups.iteritems(): | |
|
157 | if url != auth.get('url'): | |
|
158 | continue | |
|
152 | if res: | |
|
153 | group, auth = res | |
|
154 | ||
|
155 | repo.ui.debug("using auth.%s.* for authentication\n" % group) | |
|
156 | ||
|
159 | 157 | token = auth.get('phabtoken') |
|
160 | if token: | |
|
161 | break | |
|
162 | 158 | |
|
163 | 159 | if not token: |
|
164 | 160 | token = readlegacytoken(repo, url) |
General Comments 0
You need to be logged in to leave comments.
Login now