Exemplo n.º 1
0
        /// <summary>
        /// Verify client id & secret
        /// </summary>
        public virtual async Task <MessageResult <IClient> > VerifyClientAsync(NetworkCredential credential)
        {
            var mr = new MessageResult <IClient>();

            var client = await _clientStore.GetClientAsync(credential.UserName);

            if (client == null)
            {
                mr.MsgCode            = OAuth2Consts.Err_invalid_client;
                mr.MsgCodeDescription = "client not exists";
                _logger.LogWarning(mr.MsgCodeDescription);
                return(mr);
            }

            if (credential.Password != client.Secret)
            {
                mr.MsgCode            = OAuth2Consts.Err_invalid_client;
                mr.MsgCodeDescription = "invalid client";
                _logger.LogWarning(mr.MsgCodeDescription);
                return(mr);
            }

            mr.Result = client;
            return(mr);
        }