Ejemplo n.º 1
0
        protected void ValidClient()
        {
            var client = OAuthService.GetClientAuth(ClientId);

            if (client == null)
            {
                OAuthError(AccessTokenRequestErrorCode.InvoidClient, "client id invalid.");
            }
            if (client.Status != ClientAuthStatus.Enabled)
            {
                OAuthError(AccessTokenRequestErrorCode.UnauthorizedClient, "client unauthorized", 401);
            }
            if (ClientSecret != client.Secret)
            {
                OAuthError(AccessTokenRequestErrorCode.InvoidClient, "client secret invalid.");
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 授权验证
        /// </summary>
        /// <returns>授权码</returns>
        public virtual AuthorizationCode Authorize()
        {
            var client = OAuthService.GetClientAuth(ClientId);

            if (client == null)
            {
                OAuthError(AccessTokenRequestErrorCode.InvoidClient, "client id invalid.");
            }
            if (client.Status == ClientAuthStatus.Disabled)
            {
                OAuthError(AccessTokenRequestErrorCode.UnauthorizedClient, "client unauthorized", 401);
            }

            var redirectUri = new Uri(client.CallbackPath);

            if (!String.Equals(RedirectUri.AbsolutePath, redirectUri.AbsolutePath, StringComparison.InvariantCulture))
            {
                OAuthError(AccessTokenRequestErrorCode.RedirectUriMismatch, "redirect uri mismatch.");
            }
            return(null);
        }