Пример #1
0
        /// <summary>
        /// Builds the model. Override this to add information about the application requesting user consent, such as publisher information or a logo URL.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <returns>Returns the model.</returns>
        protected virtual AuthorizationServerViewModel BuildModel(OAuthMessage message)
        {
            var model = new AuthorizationServerViewModel();

            var applicationRegistration = ApplicationRegistrationService.GetApplication(message.Parameters["client_id"]);

            model.ApplicationName = applicationRegistration.ApplicationName;
            model.ApplicationUrl  = applicationRegistration.ApplicationUrl;

            return(model);
        }
Пример #2
0
        public virtual ActionResult Index_Post(AuthorizationServerViewModel model)
        {
            var message = TempData[OauthMessageKey] as OAuthMessage;

            if (model.Authorize)
            {
                string code = ApplicationRegistrationService.GetAuthorizationCode(message.Parameters[OAuthConstants.ClientId], GetDelegatedIdentity(), message.Parameters[OAuthConstants.Scope]);
                if (code != null)
                {
                    return(Redirect(message.GetCodeResponseUri(code)));
                }
                else
                {
                    return(Redirect(message.GetErrorResponseUri(OAuthConstants.ErrorCode.AccessDenied, "Error generating Authorization code. Please check if the Service Identity and the Replying Party are correct.")));
                }
            }
            else
            {
                return(Redirect(message.GetErrorResponseUri(OAuthConstants.ErrorCode.AccessDenied, "The end user has denied consent to access the requested resource")));
            }
        }
        public virtual ActionResult Index_Post(AuthorizationServerViewModel model)
        {
            var message = StoreIncomingRequest(HttpContext);

            if (message != null && message.Parameters[OAuthConstants.GrantType] == OAuthConstants.AccessGrantType.ClientCredentials)
            {
                string code = ApplicationRegistrationService.GetAuthorizationCode(message.Parameters[OAuthConstants.ClientId], GetDelegatedIdentity(), message.Parameters[OAuthConstants.Scope]);
                if (code != null)
                {
                    return(Redirect(message.GetCodeResponseUri(code)));
                }
                else
                {
                    return(Redirect(message.GetErrorResponseUri(OAuthConstants.ErrorCode.AccessDenied, "Error generating Authorization code. Please check if the Service Identity and the Replying Party are correct.")));
                }
            }
            else
            {
                return(Redirect(message.GetErrorResponseUri(OAuthConstants.ErrorCode.UnsupportedGrantType, "The provided grant type is not supported by this endpoint")));
            }
        }