Exemple #1
0
        private void SsoModelTest()
        {
            // {"is_emory_user":false,"user_id":"ad|Auth0Dev1Temp|ea441d09-2153-4e39-9d61-668af1b18605","user_nickname":"jwhitfill2","user_name":"Jody Whitfill","user_email":"*****@*****.**","user_dc":"CN=Jody Whitfill,OU=Company Users,DC=Auth0Dev1Temp,DC=com","sso_user":false}
            // https://emory.com
            var claims = new List <Claim>
            {
                //new Claim ("user_dc", "CN=Jody Whitfill,OU=Company Users,DC=Auth0Dev1Temp,DC=com"),
                //new Claim ("user_nickname", "jwhitfill2"),
                //new Claim ("user_name", "John Doe"),
                //new Claim ("user_id", "E6135E34-CC95-4576-8C93-D5404999802B"),
                //new Claim ("user_email", "*****@*****.**"),
                //new Claim ("https://emory.com", "{\"https://emory.com\":false,\"user_id\":\"ad|Auth0Dev1Temp|ea441d09-2153-4e39-9d61-668af1b18605\",\"user_nickname\":\"jwhitfill2\",\"user_name\":\"Jody Whitfill\",\"user_email\":\"[email protected]\",\"user_dc\":\"CN=Jody Whitfill,OU=Company Users,DC=Auth0Dev1Temp,DC=com\",\"sso_user\":false}"),
                new Claim("https://emory.com", "{\"https://emory.com\":false,\"user_id\":\"ad|Auth0Dev1Temp\",\"user_nickname\":\"jwhitfill2\",\"user_dc\":\"CN=Jody Whitfill,OU=Company Users,DC=Auth0Dev1Temp,DC=com\",\"sso_user\":false}"),
                //new Claim ("", ""),
                //new Claim ("", ""),
                //new Claim ("", ""),
                //new Claim ("", ""),
            };

            var ssoModel = new SsoModel(claims)
            {
                AppId       = "E6135E34-CC95-4576-8C93-D5404999802B",
                IsEmoryUser = true,
                IsSsoUser   = true
            };

            //ssoModel.UserName = "******"; // string.Empty;
            //ssoModel.NickName = "abc";
            ValidateAndShowValidationResult(ssoModel, nameof(ssoModel));
        }
Exemple #2
0
        // GET: Account/Login
        public ActionResult Login(string rurl)
        {
            //if (ConfigurationSettings.AppSettings["IsUseSSO"] != null && ConfigurationSettings.AppSettings["IsUseSSO"].ToLower() == "true")
            //{
            SsoModel ssoModel = new SsoModel();

            ssoModel.Appkey     = ConfigurationManager.AppSettings["SsoAppId"];
            ssoModel.Appsecret  = ConfigurationManager.AppSettings["SsoAppSecret"];
            ssoModel.SsoBaseUrl = ConfigurationManager.AppSettings["SsoHost"];

            if (ssoModel.IsNeedValidateHylId())
            {
                string userinfoStr = ssoModel.ValidateHylId();
                ResponseModel <Users> userModel = JsonConvert.DeserializeObject <ResponseModel <Users> >(userinfoStr);
                if (userModel != null && userModel.Data != null)
                {
                    WebWorkContext.AdminUser   = userModel.Data;
                    WebWorkContext.AuthorityId = (int)AuthorityEnum.Admin;
                }
            }

            if (WebWorkContext.AdminUser == null)
            {
                ssoModel.ToSsoPage(Request.Url.AbsoluteUri);
            }
            if (!string.IsNullOrEmpty(rurl))
            {
                return(Redirect(rurl));
            }
            return(RedirectToAction("Index", "Survey"));
            //}
        }
Exemple #3
0
        public ActionResult LoginOut()
        {
            WebWorkContext.LoginOut();
            //if (ConfigurationSettings.AppSettings["IsUseSSO"] != null &&
            //    ConfigurationSettings.AppSettings["IsUseSSO"].ToLower() == "true")
            //{
            SsoModel ssoModel = new SsoModel();

            ssoModel.Appkey     = ConfigurationManager.AppSettings["SsoAppId"];
            ssoModel.Appsecret  = ConfigurationManager.AppSettings["SsoAppSecret"];
            ssoModel.SsoBaseUrl = ConfigurationManager.AppSettings["SsoHost"];
            ssoModel.LoginOut(Request.Url.AbsoluteUri.ToLower().Replace("loginout", "Login"));
            //}
            //else
            //{
            //    return RedirectToAction("Index");
            //}
            return(RedirectToAction("Login"));
        }