/**
         * get token from etcd with name and password.
         *
         * @param channel channel to etcd
         * @param username auth name
         * @param password auth password
         * @return authResp
         */
        private static AuthenticateResponse Authenticate(Channel channel, ByteSequence username, ByteSequence password)
        {
            AuthenticateRequest requet = new AuthenticateRequest();

            requet.Name     = username.ToString();
            requet.Password = password.ToString();
            Auth.AuthClient      authClient = new Auth.AuthClient(channel);
            var                  rsp        = authClient.Authenticate(requet);
            AuthenticateResponse response   = new AuthenticateResponse(rsp);

            return(response);
        }
Esempio n. 2
0
        /// <summary>
        /// Used to authenticate etcd server through basic auth
        /// </summary>
        private void Authenticate()
        {
            _authClient = new Auth.AuthClient(_channel);
            AuthenticateResponse authRes = _authClient.Authenticate(new AuthenticateRequest
            {
                Name     = _username,
                Password = _password
            });

            _authToken = authRes.Token;
            _headers   = new Metadata
            {
                { "Authorization", _authToken }
            };
        }
Esempio n. 3
0
        /// <summary>
        /// Used to authenticate etcd server through basic auth
        /// </summary>
        private void Authenticate()
        {
            var authChannel = new Channel(_host, ChannelCredentials.Insecure);

            _authClient = new Auth.AuthClient(authChannel);
            var authRes = _authClient.Authenticate(new AuthenticateRequest
            {
                Name     = _username,
                Password = _password
            });
            var shutdownAsync = authChannel.ShutdownAsync();

            shutdownAsync.Dispose();
            _authToken = authRes.Token;
            _headers   = new Metadata
            {
                { "Authorization", _authToken }
            };
        }