mirror of
https://github.com/facebook/sapling.git
synced 2024-10-10 16:57:49 +03:00
use authentication abstraction for mononoke
Summary: This allows us to be more flexible in choosing authentication and expands variables used in configuration. Reviewed By: singhsrb Differential Revision: D25304008 fbshipit-source-id: 636893a9eaec31ca5acfa02f72931d5e56b695d0
This commit is contained in:
parent
e1db6b8753
commit
d3224db357
@ -428,13 +428,13 @@ ack=*
|
||||
changegroup3=True
|
||||
[mutation]
|
||||
record=False
|
||||
[mononokepeer]
|
||||
cn=localhost
|
||||
[web]
|
||||
cacerts=$TEST_CERTDIR/root-ca.crt
|
||||
[auth]
|
||||
edenapi.cert=$TEST_CERTDIR/localhost.crt
|
||||
edenapi.key=$TEST_CERTDIR/localhost.key
|
||||
mononoke.cert=$TEST_CERTDIR/localhost.crt
|
||||
mononoke.key=$TEST_CERTDIR/localhost.key
|
||||
mononoke.prefix=mononoke://*
|
||||
mononoke.cn=localhost
|
||||
EOF
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@ import socket
|
||||
from enum import Enum
|
||||
from struct import pack, unpack
|
||||
|
||||
from . import error, progress, sslutil, util, stdiopeer
|
||||
from . import error, progress, httpconnection, sslutil, util, stdiopeer
|
||||
from .i18n import _
|
||||
from .pycompat import decodeutf8, encodeutf8
|
||||
|
||||
@ -192,14 +192,19 @@ class mononokepeer(stdiopeer.stdiopeer):
|
||||
self._host = u.host
|
||||
self._port = u.port or 443
|
||||
self._path = u.path
|
||||
self._cn = ui.config("mononokepeer", "cn") or self._host
|
||||
|
||||
# Let's share certificate finding logic with EdenAPI
|
||||
self._cert = ui.config("auth", "edenapi.cert")
|
||||
self._key = ui.config("auth", "edenapi.key")
|
||||
authdata = httpconnection.readauthforuri(self._ui, path, self._user)
|
||||
if not authdata:
|
||||
self._abort(
|
||||
error.RepoError(
|
||||
_("missing auth configuration for connecting to mononoke")
|
||||
)
|
||||
)
|
||||
|
||||
if self._cert is None or self._key is None:
|
||||
self._abort(error.RepoError(_("missing certificate or private key")))
|
||||
(authname, auth) = authdata
|
||||
self._cert = auth.get("cert")
|
||||
self._key = auth.get("key")
|
||||
self._cn = auth.get("cn") or self._host
|
||||
|
||||
if create:
|
||||
self._abort(
|
||||
|
Loading…
Reference in New Issue
Block a user