Beispiel #1
0
 public ActionResult PrepareAuthRequest(IAuthProviderDefinition def, string username, Uri returnTo)
 {
     return(Do(def, r =>
               Configs.EmptyIfNull().Aggregate(r, (rr, c) => { c.Config(rr); return rr; })
               .PrepareRequestUserAuthorization(null, returnTo).AsActionResult()
               ));
 }
Beispiel #2
0
        public IAuthResult GetResult(IAuthProviderDefinition def)
        {
            if (!(def is OpenIdProvider))
            {
                return(null);
            }

            var r = _openid.GetResponse(HttpContext.Request);

            return(r == null || r.Status != AuthenticationStatus.Authenticated ? null : new OpenIdAuthResult(r));
        }
Beispiel #3
0
        T Do <T>(IAuthProviderDefinition def, Func <WebServerClient, T> f)
        {
            var provider = def as OAuthProvider;

            if (provider == null)
            {
                return(default(T));
            }

            var r = new WebServerClient(provider.Description, provider.ClientIdentifier, provider.CredentialApplicator);

            return(f(r));
        }
Beispiel #4
0
        public IAuthResult GetResult(IAuthProviderDefinition def)
        {
            return(Do(def, r =>
            {
                var s = r.ProcessUserAuthorization(HttpContext.Request);
                if (s == null)
                {
                    return null;
                }

                var content = new WebClient().DownloadString("https://graph.facebook.com/me?access_token=" + s.AccessToken);
                var fields = new JavaScriptSerializer().Deserialize <Dictionary <string, object> >(content);
                return new OAuthResult(s, fields);
            }));
        }
Beispiel #5
0
        public ActionResult PrepareAuthRequest(IAuthProviderDefinition def, string username, Uri returnTo)
        {
            var provider = def as OpenIdProvider;

            if (provider == null)
            {
                return(null);
            }

            var r = _openid.CreateRequest(Identifier.Parse(string.Format(provider.Id, username)), Realm.AutoDetect, returnTo);

            foreach (var c in Configs.EmptyIfNull())
            {
                c.Config(r);
            }

            return(r.RedirectingResponse.AsActionResult());
        }