Пример #1
0
        private ActionResult RedirectToOAuth2IdentityProvider(IdentityProvider ip, SignInRequestMessage request)
        {
            var ctx = new OAuth2Context
            {
                Wctx  = request.Context,
                Realm = request.Realm,
                IdP   = ip.ID
            };

            SetOAuthContextCookie(ctx);

            var oauth2 = new OAuth2Client(GetProviderTypeFromOAuthProfileTypes(ip.ProviderType.Value), ip.ClientID, ip.ClientSecret);

            switch (ip.ProviderType)
            {
            case OAuth2ProviderTypes.Google:
                return(new OAuth2ActionResult(oauth2, ProviderType.Google, null));

            case OAuth2ProviderTypes.Facebook:
                return(new OAuth2ActionResult(oauth2, ProviderType.Facebook, null));

            case OAuth2ProviderTypes.Live:
                return(new OAuth2ActionResult(oauth2, ProviderType.Live, null));
            }

            return(View("Error"));
        }
Пример #2
0
        private void SetOAuthContextCookie(OAuth2Context ctx)
        {
            var j = JObject.FromObject(ctx);

            var cookie = new HttpCookie(_cookieOAuthContext, HttpUtility.UrlEncode(j.ToString()));

            cookie.Secure   = true;
            cookie.HttpOnly = true;
            cookie.Path     = Request.ApplicationPath;

            Response.Cookies.Add(cookie);
        }
Пример #3
0
        private void SetOAuthContextCookie(OAuth2Context ctx)
        {
            var j = JObject.FromObject(ctx);

            var cookie = new HttpCookie("idsrvoauthcontext", j.ToString());

            cookie.Secure   = true;
            cookie.HttpOnly = true;
            cookie.Path     = Request.ApplicationPath;

            Response.Cookies.Add(cookie);
        }
        private void SetOAuthContextCookie(OAuth2Context ctx)
        {
            var j = JObject.FromObject(ctx);

            var cookie = new HttpCookie(_cookieOAuthContext, HttpUtility.UrlEncode(j.ToString()));
            cookie.Secure = true;
            cookie.HttpOnly = true;
            cookie.Path = Request.ApplicationPath;

            Response.Cookies.Add(cookie);
        }
        private ActionResult RedirectToOAuth2IdentityProvider(IdentityProvider ip, SignInRequestMessage request)
        {
            var ctx = new OAuth2Context
            {
                Wctx = request.Context,
                Realm = request.Realm,
                IdP = ip.ID
            };

            SetOAuthContextCookie(ctx);

            var oauth2 = new OAuth2Client(GetProviderTypeFromOAuthProfileTypes(ip.ProviderType.Value), ip.ClientID, ip.ClientSecret);
            switch (ip.ProviderType)
            {
                case OAuth2ProviderTypes.Google:
                    return new OAuth2ActionResult(oauth2, ProviderType.Google, null);
                case OAuth2ProviderTypes.Facebook:
                    return new OAuth2ActionResult(oauth2, ProviderType.Facebook, null);
                case OAuth2ProviderTypes.Live:
                    return new OAuth2ActionResult(oauth2, ProviderType.Live, null);
                case OAuth2ProviderTypes.LinkedIn:
                    return new OAuth2ActionResult(oauth2, ProviderType.LinkedIn, null);
            }

            return View("Error");
        }
        private void SetOAuthContextCookie(OAuth2Context ctx)
        {
            var j = JObject.FromObject(ctx);

            var cookie = new HttpCookie("idsrvoauthcontext", j.ToString());
            cookie.Secure = true;
            cookie.HttpOnly = true;
            cookie.Path = Request.ApplicationPath;

            Response.Cookies.Add(cookie);
        }