public Task ApplyChallenge(OAuthChallengeContext context)
        {
            //if token invalid

            //context.Response.Redirect("/Account/Login");
            return(Task.FromResult <object>(null));
        }
        public Task ApplyChallenge(OAuthChallengeContext context)
        {
            //為了回傳Task void, 隨便傳入一個值
            return(Task.FromResult(0));

            //.net framework 4.6才有
            //return Task.CompletedTask
        }
        /// <summary>
        /// Called each time a challenge is being sent to the client. By implementing this method the application
        /// may modify the challenge as needed.
        /// </summary>
        /// <param name="context">Contains the default challenge.</param>
        /// <returns>
        /// A <see cref="T:System.Threading.Tasks.Task" /> representing the completed operation.
        /// </returns>
        /// <exception cref="System.NotImplementedException"></exception>
        public Task ApplyChallenge(OAuthChallengeContext context)
        {
            if (_inner != null)
            {
                return(_inner.ApplyChallenge(context));
            }

            return(Task.FromResult(0));
        }
Exemplo n.º 4
0
        protected override Task ApplyResponseChallengeAsync()
        {
            if (Response.StatusCode != 401)
            {
                return(Task.FromResult <object>(null));
            }

            AuthenticationResponseChallenge challenge = Helper.LookupChallenge(Options.AuthenticationType, Options.AuthenticationMode);

            if (challenge != null)
            {
                OAuthChallengeContext challengeContext = new OAuthChallengeContext(Context, this.challenge);
                Options.Provider.ApplyChallenge(challengeContext);
            }

            return(Task.FromResult <object>(null));
        }
Exemplo n.º 5
0
        private static Task HandleOnApplyChallenge(
            OAuthChallengeContext context,
            OAuthSiteInfo site)
        {
            UriBuilder          authorizeUri = new UriBuilder(new Uri(new Uri(site.AuthorityUri.WithPostfix('/')), "authorize"));
            NameValueCollection query        =
                new NameValueCollection(5)
            {
                { "client_id", site.ClientId },
                { "redirect_uri", site.RedirectUri },
                { "response_type", "code" },
                { "scope", site.Scope },
                { "locale", Context.Language.CultureInfo.Name }
            };

            authorizeUri.Query = query.ToQueryString();
            context.Response.Redirect(authorizeUri.ToString());
            return(Task.CompletedTask);
        }
Exemplo n.º 6
0
 /// <summary>
 /// Token验证失败
 /// </summary>
 /// <param name="context"></param>
 /// <returns></returns>
 private static Task HandlerApplyChallenge(OAuthChallengeContext context)
 {
     //默认返回401
     return(Task.FromResult(0));
 }
 public Task ApplyChallenge(OAuthChallengeContext context)
 {
     context.OwinContext.Response.Headers.AppendValues("WWW-Authenticate", context.Challenge);
     return(Task.FromResult(0));
 }
Exemplo n.º 8
0
 public Task ApplyChallenge(OAuthChallengeContext context)
 {
     return(Task.FromResult <object>(null));
 }
Exemplo n.º 9
0
 public Task ApplyChallenge(OAuthChallengeContext context)
 {
     return(null);
 }
 public Task ApplyChallenge(OAuthChallengeContext context)
 {
     return(Task.FromResult(0));
 }
Exemplo n.º 11
0
 public Task ApplyChallenge(OAuthChallengeContext context)
 {
     //context.Validated();
     return(Task.FromResult(0));
 }
 public Task ApplyChallenge(OAuthChallengeContext context)
 {
     return(Task.CompletedTask);
 }
Exemplo n.º 13
0
 public Task ApplyChallenge(OAuthChallengeContext context)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 14
0
 public Task ApplyChallenge(OAuthChallengeContext context)
 {
     context.Response.Redirect("/user/login");
     return(Task.FromResult <object>(null));
 }
 public Task OAuthResponseChangeEventTask(OAuthChallengeContext context)
 {
     return(base.OnApplyChallenge(context));
 }