• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Auth.AuthUserSession类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中ServiceStack.Auth.AuthUserSession的典型用法代码示例。如果您正苦于以下问题:C# AuthUserSession类的具体用法?C# AuthUserSession怎么用?C# AuthUserSession使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



AuthUserSession类属于ServiceStack.Auth命名空间,在下文中一共展示了AuthUserSession类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: LoadUserAuthInfo

        protected override void LoadUserAuthInfo(AuthUserSession userSession, IAuthTokens tokens, Dictionary<string, string> authInfo)
        {
            if (authInfo.ContainsKey("user_id"))
                tokens.UserId = authInfo.GetValueOrDefault("user_id");

            if (authInfo.ContainsKey("screen_name"))
                tokens.UserName = authInfo.GetValueOrDefault("screen_name");

            try
            {
                if (tokens.UserId != null)
                {
                    var oauthToken = new OAuthAccessToken
                    {
                        OAuthProvider = this,
                        AccessToken = tokens.AccessToken,
                        AccessTokenSecret = tokens.AccessTokenSecret,
                    };
                    var json = AuthHttpGateway.DownloadTwitterUserInfo(oauthToken, tokens.UserId);
                    var objs = JsonObject.ParseArray(json);
                    if (objs.Count > 0)
                    {
                        var obj = objs[0];
                        tokens.DisplayName = obj.Get("name");

                        string profileUrl;
                        if (obj.TryGetValue("profile_image_url", out profileUrl))
                            tokens.Items[AuthMetadataProvider.ProfileUrlKey] = profileUrl;

                        if (SaveExtendedUserInfo)
                        {
                            obj.Each(x => authInfo[x.Key] = x.Value);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error($"Could not retrieve twitter user info for '{userSession.TwitterUserId}'", ex);
            }

            LoadUserOAuthProvider(userSession, tokens);
        }
开发者ID:AVee,项目名称:ServiceStack,代码行数:43,代码来源:TwitterAuthProvider.cs


示例2: LoadUserAuthInfo

        protected override void LoadUserAuthInfo(AuthUserSession userSession, IAuthTokens tokens, System.Collections.Generic.Dictionary<string, string> authInfo)
        {
            try
            {
                var json = AuthHttpGateway.DownloadFacebookUserInfo(tokens.AccessTokenSecret);
                var obj = JsonObject.Parse(json);
                tokens.UserId = obj.Get("id");
                tokens.UserName = obj.Get("username");
                tokens.DisplayName = obj.Get("name");
                tokens.FirstName = obj.Get("first_name");
                tokens.LastName = obj.Get("last_name");
                tokens.Email = obj.Get("email");

                LoadUserOAuthProvider(userSession, tokens);
            }
            catch (Exception ex)
            {
                Log.Error("Could not retrieve facebook user info for '{0}'".Fmt(tokens.DisplayName), ex);
            }
        }
开发者ID:TerryRen,项目名称:ServiceStack,代码行数:20,代码来源:FacebookAuthProvider.cs


示例3: LoadUserAuthInfo

        protected override void LoadUserAuthInfo(AuthUserSession userSession, IAuthTokens tokens, System.Collections.Generic.Dictionary<string, string> authInfo)
        {
            try
            {
                var json = AuthHttpGateway.DownloadFacebookUserInfo(tokens.AccessTokenSecret);
                var obj = JsonObject.Parse(json);
                tokens.UserId = obj.Get("id");
                tokens.UserName = obj.Get("username");
                tokens.DisplayName = obj.Get("name");
                tokens.FirstName = obj.Get("first_name");
                tokens.LastName = obj.Get("last_name");
                tokens.Email = obj.Get("email");

                if (SaveExtendedUserInfo)
                {
                    obj.Each(x => authInfo[x.Key] = x.Value);
                }

                json = AuthHttpGateway.DownloadFacebookUserInfo(tokens.AccessTokenSecret, "picture");
                obj = JsonObject.Parse(json);
                var picture = obj.Object("picture");
                var data = picture != null ? picture.Object("data") : null;
                if (data != null)
                {
                    string profileUrl;
                    if (data.TryGetValue("url", out profileUrl))
                        tokens.Items[AuthMetadataProvider.ProfileUrlKey] = profileUrl;
                }
            }
            catch (Exception ex)
            {
                Log.Error("Could not retrieve facebook user info for '{0}'".Fmt(tokens.DisplayName), ex);
            }

            LoadUserOAuthProvider(userSession, tokens);
        }
开发者ID:jlyonsmith,项目名称:ServiceStack,代码行数:36,代码来源:FacebookAuthProvider.cs


示例4: GetRegistrationService

		public static RegisterService GetRegistrationService(
            IUserAuthRepository userAuthRepository,
			AuthUserSession oAuthUserSession = null,
            BasicRequest request = null)
		{
			if (request == null)
                request = new BasicRequest();
			if (oAuthUserSession == null)
				oAuthUserSession = request.ReloadSession();

            oAuthUserSession.Id = request.Response.CreateSessionId(request);
            request.Items[ServiceExtensions.RequestItemsSessionKey] = oAuthUserSession;

			var mockAppHost = new BasicAppHost();

            mockAppHost.Container.Register<IAuthRepository>(userAuthRepository);

		    var authService = new AuthenticateService {
                Request = request,
            };
            authService.SetResolver(mockAppHost);
            mockAppHost.Register(authService);

			var registrationService = new RegisterService {
				AuthRepo = userAuthRepository,
				Request = request,
				RegistrationValidator =
					new RegistrationValidator { UserAuthRepo = RegistrationServiceTests.GetStubRepo() },
			};
			registrationService.SetResolver(mockAppHost);

			return registrationService;
		}
开发者ID:nustack,项目名称:ServiceStack,代码行数:33,代码来源:OAuthUserSessionTestsBase.cs


示例5: ShouldSetReferrerFromRedirectParam

        public void ShouldSetReferrerFromRedirectParam()
        {
            using (TestAppHost())
            {
                var request = new MockHttpRequest("myapp", "GET", "text", "/myapp", new NameValueCollection {
                    {"redirect", "http://localhost/myapp/secure-resource"}
                }, Stream.Null, null);
                var mockAuthService = MockAuthService(request);
                var session = new AuthUserSession();
                
                Subject.Authenticate(mockAuthService.Object, session, new Authenticate());

                session.ReferrerUrl.Should().Be("http://localhost/myapp/secure-resource");
            }
        }
开发者ID:jfoshee,项目名称:ServiceStack.Authentication.Aad,代码行数:15,代码来源:AadAuthProviderTest.cs


示例6: LoadUserAuthInfo

    protected override void LoadUserAuthInfo(AuthUserSession userSession, IAuthTokens tokens, Dictionary<string, string> authInfo)
    {
      try
      {

        //sig = md5( request_params_composed_string + md5(access_token + application_secret_key)  )

        string innerSignature = Encoding.UTF8.GetBytes(tokens.AccessTokenSecret + ConsumerSecret).ToMd5Hash();
        string signature = Encoding.UTF8.GetBytes("application_key={0}".Fmt(PublicKey) + innerSignature).ToMd5Hash();

        string payload = "access_token={0}&sig={1}&application_key={2}".Fmt(tokens.AccessTokenSecret, signature, PublicKey);

        string json = "http://api.odnoklassniki.ru/api/users/getCurrentUser".PostToUrl(payload, "*/*", RequestFilter);

        JsonObject obj = JsonObject.Parse(json);

        if (!obj.Get("error").IsNullOrEmpty())
        {
          Log.Error("Could not retrieve Odnoklassniki user info for '{0}', Response:{1}".Fmt(tokens.DisplayName, json));
          return;
        }

        //response fields info: http://apiok.ru/wiki/display/api/users.getCurrentUser+ru
        var location = JsonObject.Parse(obj.GetUnescaped("location"));

        tokens.UserId = obj.Get("uid");
        tokens.DisplayName = obj.Get("name");
        tokens.FirstName = obj.Get("first_name");
        tokens.LastName = obj.Get("last_name");
        tokens.BirthDateRaw = obj.Get("birthday");
        tokens.Language = obj.Get("locale");
        tokens.Country = location.Get("countryCode");
        tokens.City = location.Get("city");
        tokens.Gender = obj.Get("gender");

        LoadUserOAuthProvider(userSession, tokens);
      }
      catch (Exception ex)
      {
        Log.Error("Could not retrieve Odnoklassniki user info for '{0}'".Fmt(tokens.DisplayName), ex);
      }
    }
开发者ID:JackFong,项目名称:ServiceStack,代码行数:42,代码来源:OdnoklassnikiAuthProvider.cs


示例7: ShouldAbortIfStateValuesDoNotMatch

        public void ShouldAbortIfStateValuesDoNotMatch()
        {
            // If the state value in the response matches the state value in the request, 
            // the application should store the authorization code for use in the access token request.
            using (TestAppHost())
            {
                Subject.ClientId = "2d4d11a2-f814-46a7-890a-274a72a7309e";
                Subject.CallbackUrl = "http://localhost/myapp/";
                var request = new MockHttpRequest("myapp", "GET", "text", "/myapp", new NameValueCollection {
                    {"code", "code123"},
                    {"session_state", "dontcare"},
                    {"state", "state123" }
                }, Stream.Null, null);
                var mockAuthService = MockAuthService(request);
                using (new HttpResultsFilter
                {
                    StringResultFn = tokenRequest =>
                    {
                        Assert.Fail("Should never have made token request since the state was not matched");
                        return @"{
                          ""access_token"": ""fake token"",
                          ""id_token"": ""eyJ0eXAiOiJKV1QiLCJhbGciOiJub25lIn0.eyJhdWQiOiIyZDRkMTFhMi1mODE0LTQ2YTctODkwYS0yNzRhNzJhNzMwOWUiLCJpc3MiOiJodHRwczovL3N0cy53aW5kb3dzLm5ldC83ZmU4MTQ0Ny1kYTU3LTQzODUtYmVjYi02ZGU1N2YyMTQ3N2UvIiwiaWF0IjoxMzg4NDQwODYzLCJuYmYiOjEzODg0NDA4NjMsImV4cCI6MTM4ODQ0NDc2MywidmVyIjoiMS4wIiwidGlkIjoiN2ZlODE0NDctZGE1Ny00Mzg1LWJlY2ItNmRlNTdmMjE0NzdlIiwib2lkIjoiNjgzODlhZTItNjJmYS00YjE4LTkxZmUtNTNkZDEwOWQ3NGY1IiwidXBuIjoiZnJhbmttQGNvbnRvc28uY29tIiwidW5pcXVlX25hbWUiOiJmcmFua21AY29udG9zby5jb20iLCJzdWIiOiJKV3ZZZENXUGhobHBTMVpzZjd5WVV4U2hVd3RVbTV5elBtd18talgzZkhZIiwiZmFtaWx5X25hbWUiOiJNaWxsZXIiLCJnaXZlbl9uYW1lIjoiRnJhbmsifQ.""
                        }";

                    }
                })
                {
                    var session = new AuthUserSession
                    {
                        State = "state133" // Not the same as the state in the request above
                    };

                    try { Subject.Authenticate(mockAuthService.Object, session, new Authenticate()); }
                    catch (UnauthorizedAccessException){}

                    session.IsAuthenticated.Should().BeFalse("Should not be authenticated");
                }
            }
        }
开发者ID:jfoshee,项目名称:ServiceStack.Authentication.Aad,代码行数:39,代码来源:AadAuthProviderTest.cs


示例8: VerifyNotAuthenticatedByToken

        private void VerifyNotAuthenticatedByToken()
        {
            Subject.CallbackUrl = "http://localhost/myapp/";
            using (TestAppHost())
            {
                var request = new MockHttpRequest("myapp", "GET", "text", "/myapp", new NameValueCollection
                {
                    {"code", "code123"},
                    {"state", "D79E5777-702E-4260-9A62-37F75FF22CCE"}
                }, Stream.Null, null);
                var mockAuthService = MockAuthService(request);
                using (new HttpResultsFilter
                {
                    StringResult =
                        @"{
                          ""access_token"": ""token456"",
                          ""id_token"": ""eyJ0eXAiOiJKV1QiLCJhbGciOiJub25lIn0.eyJhdWQiOiIyZDRkMTFhMi1mODE0LTQ2YTctODkwYS0yNzRhNzJhNzMwOWUiLCJpc3MiOiJodHRwczovL3N0cy53aW5kb3dzLm5ldC83ZmU4MTQ0Ny1kYTU3LTQzODUtYmVjYi02ZGU1N2YyMTQ3N2UvIiwiaWF0IjoxMzg4NDQwODYzLCJuYmYiOjEzODg0NDA4NjMsImV4cCI6MTM4ODQ0NDc2MywidmVyIjoiMS4wIiwidGlkIjoiN2ZlODE0NDctZGE1Ny00Mzg1LWJlY2ItNmRlNTdmMjE0NzdlIiwib2lkIjoiNjgzODlhZTItNjJmYS00YjE4LTkxZmUtNTNkZDEwOWQ3NGY1IiwidXBuIjoiZnJhbmttQGNvbnRvc28uY29tIiwidW5pcXVlX25hbWUiOiJmcmFua21AY29udG9zby5jb20iLCJzdWIiOiJKV3ZZZENXUGhobHBTMVpzZjd5WVV4U2hVd3RVbTV5elBtd18talgzZkhZIiwiZmFtaWx5X25hbWUiOiJNaWxsZXIiLCJnaXZlbl9uYW1lIjoiRnJhbmsifQ.""
                        }"
                })
                {
                    var session = new AuthUserSession();

                    try{ Subject.Authenticate(mockAuthService.Object, session, new Authenticate()); }
                    catch (UnauthorizedAccessException){}

                    session.IsAuthenticated.Should().BeFalse();
                }
            }
        }
开发者ID:jfoshee,项目名称:ServiceStack.Authentication.Aad,代码行数:29,代码来源:AadAuthProviderTest.cs


示例9: Register

        protected object Register(IUserAuthRepository userAuthRepository, AuthUserSession oAuthUserSession, Register register = null)
		{
			if (register == null)
				register = RegisterDto;

			var registrationService = GetRegistrationService(userAuthRepository, oAuthUserSession, requestContext);
			var response = registrationService.Post(register);
			Assert.That(response as IHttpError, Is.Null);
			return response;
		}
开发者ID:nustack,项目名称:ServiceStack,代码行数:10,代码来源:OAuthUserSessionTestsBase.cs


示例10: GetNewSession2

		public static AuthUserSession GetNewSession2()
		{
			var oAuthUserSession = new AuthUserSession();
			return oAuthUserSession;
		}
开发者ID:nustack,项目名称:ServiceStack,代码行数:5,代码来源:OAuthUserSessionTestsBase.cs


示例11: GetRegistrationService

		public static RegisterService GetRegistrationService(
			IUserAuthRepository userAuthRepository,
			AuthUserSession oAuthUserSession = null,
			MockRequestContext requestContext = null)
		{
			if (requestContext == null)
				requestContext = new MockRequestContext();
			if (oAuthUserSession == null)
				oAuthUserSession = requestContext.ReloadSession();

			var httpReq = requestContext.Get<IHttpRequest>();
			var httpRes = requestContext.Get<IHttpResponse>();
			oAuthUserSession.Id = httpRes.CreateSessionId(httpReq);
			httpReq.Items[ServiceExtensions.RequestItemsSessionKey] = oAuthUserSession;

			var mockAppHost = new BasicAppHost {
				Container = requestContext.Container
			};

			requestContext.Container.Register(userAuthRepository);

		    var authService = new AuthenticateService {
                RequestContext = requestContext,
            };
            authService.SetResolver(mockAppHost);
            mockAppHost.Register(authService);

			var registrationService = new RegisterService {
				UserAuthRepo = userAuthRepository,
				RequestContext = requestContext,
				RegistrationValidator =
					new RegistrationValidator { UserAuthRepo = RegistrationServiceTests.GetStubRepo() },
			};
			registrationService.SetResolver(mockAppHost);

			return registrationService;
		}
开发者ID:ELHANAFI,项目名称:ServiceStack,代码行数:37,代码来源:OAuthUserSessionTestsBase.cs


示例12: LoadUserAuthInfo

        /// <summary>
        /// Load the UserAuth info into the session.
        /// </summary>
        /// <param name="userSession">
        /// The User session.
        /// </param>
        /// <param name="tokens">
        /// The OAuth tokens.
        /// </param>
        /// <param name="authInfo">
        /// The auth info.
        /// </param>
        protected override void LoadUserAuthInfo(AuthUserSession userSession, IAuthTokens tokens, Dictionary<string, string> authInfo)
        {
            try
            {
                var contents = AuthHttpGateway.DownloadYammerUserInfo(tokens.UserId);

                var authObj = JsonObject.Parse(contents);

                tokens.UserId = authObj.Get("id");
                tokens.UserName = authObj.Get("name");
                tokens.DisplayName = authObj.Get("full_name");
                tokens.FullName = authObj.Get("full_name");
                tokens.FirstName = authObj.Get("first_name");
                tokens.LastName = authObj.Get("last_name");

                var emails = authObj.Object("contact").ArrayObjects("email_addresses").ConvertAll(x =>
                    new EmailAddresses
                    {
                        Type = x.Get("type"),
                        Address = x.Get("address")
                    });

                var email = emails.FirstOrDefault(q => q.Type == "primary");
                if (email != null)
                {
                    tokens.Email = email.Address;
                }

                // Pass along
                this.LoadUserOAuthProvider(userSession, tokens);
            }
            catch (Exception ex)
            {
                Log.Error("Could not retrieve Yammer user info for '{0}'".Fmt(tokens.DisplayName), ex);
            }
        }
开发者ID:GDBSD,项目名称:ServiceStack,代码行数:48,代码来源:YammerAuthProvider.cs


示例13: LoadUserAuthInfo

        protected override void LoadUserAuthInfo(AuthUserSession userSession, IAuthTokens tokens, Dictionary<string, string> authInfo)
        {
            try
            {
                string json = "https://login.yandex.ru/info?format=json&oauth_token={0}".Fmt(tokens.AccessTokenSecret).GetJsonFromUrl();
                JsonObject obj = JsonObject.Parse(json);

                tokens.UserId = obj.Get("id");
                tokens.UserName = obj.Get("display_name");
                tokens.DisplayName = obj.Get("real_name");
                tokens.FirstName = obj.Get("first_name");
                tokens.LastName = obj.Get("last_name");
                tokens.Email = obj.Get("default_email");
                tokens.BirthDateRaw = obj.Get("birthday");

                LoadUserOAuthProvider(userSession, tokens);
            }
            catch (Exception ex)
            {
                Log.Error("Could not retrieve Yandex user info for '{0}'".Fmt(tokens.DisplayName), ex);
            }
        }
开发者ID:jin29neci,项目名称:ServiceStack,代码行数:22,代码来源:YandexAuthProvider.cs


示例14: LoadUserAuthInfo

        protected override void LoadUserAuthInfo(AuthUserSession userSession, IAuthTokens tokens, Dictionary<string, string> authInfo)
        {
            try
            {
                tokens.UserId = authInfo["user_id"];
                tokens.UserName = authInfo["username"];
                tokens.DisplayName = authInfo["name"];
                tokens.FirstName = authInfo["first_name"];
                tokens.LastName = authInfo["last_name"];
                tokens.Email = authInfo["email"];
                userSession.UserAuthName = tokens.Email;

                this.LoadUserOAuthProvider(userSession, tokens);
            }
            catch (Exception ex)
            {
                Log.Error("Could not retrieve Profile info for '{0}'".Fmt(tokens.DisplayName), ex);
            }
        }
开发者ID:GDBSD,项目名称:ServiceStack,代码行数:19,代码来源:OAuth2Provider.cs


示例15: LoadUserAuthInfo

        public void LoadUserAuthInfo(AuthUserSession userSession, IAuthTokens tokens, Dictionary<string, string> authInfo)
        {
            if (userSession == null)
                return;

            try
            {
                using (PrincipalContext pc = new PrincipalContext(ContextType.Domain))
                {
                    var user = UserPrincipal.FindByIdentity(pc, userSession.UserAuthName);

                    tokens.DisplayName = user.DisplayName;
                    tokens.Email = user.EmailAddress;
                    tokens.FirstName = user.GivenName;
                    tokens.LastName = user.Surname;
                    tokens.FullName = (String.IsNullOrWhiteSpace(user.MiddleName))
                        ? "{0} {1}".Fmt(user.GivenName, user.Surname)
                        : "{0} {1} {2}".Fmt(user.GivenName, user.MiddleName, user.Surname);
                    tokens.PhoneNumber = user.VoiceTelephoneNumber;
                }
            }
            catch (MultipleMatchesException mmex)
            {
                Log.Error("Multiple windows user info for '{0}'".Fmt(userSession.UserAuthName), mmex);
            }
            catch (Exception ex)
            {
                Log.Error("Could not retrieve windows user info for '{0}'".Fmt(tokens.DisplayName), ex);
            }
        }
开发者ID:JackFong,项目名称:ServiceStack,代码行数:30,代码来源:AppHost.cs


示例16: LoadUserAuthInfo

        protected override void LoadUserAuthInfo(AuthUserSession userSession, IAuthTokens tokens, Dictionary<string, string> authInfo)
        {
            tokens.Gender = authInfo["gender"];
            if (tokens.Gender != "none")
                userSession.Gender = tokens.Gender;

            if (authInfo.ContainsKey("phone"))
                tokens.PhoneNumber = authInfo["phone"];
            userSession.PhoneNumber = tokens.PhoneNumber ?? userSession.PhoneNumber;

            if (authInfo.ContainsKey("birthday"))
            {
                tokens.BirthDateRaw = authInfo["birthday"];                

                long unixDateTime;
                if (long.TryParse(tokens.BirthDateRaw, out unixDateTime))
                {
                    tokens.BirthDate = unixDateTime.FromUnixTime();
                }
            }
            userSession.BirthDateRaw = tokens.BirthDateRaw ?? userSession.BirthDateRaw;
            userSession.BirthDate = tokens.BirthDate ?? userSession.BirthDate;

            if (authInfo.ContainsKey("facebook"))
                userSession.FacebookUserId = authInfo["facebook"];

            if (authInfo.ContainsKey("twitter"))
                userSession.TwitterUserId = authInfo["twitter"];

            base.LoadUserAuthInfo(userSession, tokens, authInfo);
        }
开发者ID:jin29neci,项目名称:ServiceStack,代码行数:31,代码来源:FourSquareOAuth2Provider.cs


示例17: ShouldSaveExtendedInfoFromPayload

        public void ShouldSaveExtendedInfoFromPayload()
        {
            using (TestAppHost())
            {
                Subject.SaveExtendedUserInfo = true;
                Subject.ClientId = "2d4d11a2-f814-46a7-890a-274a72a7309e";
                var request = new MockHttpRequest("myapp", "GET", "text", "/myapp", new NameValueCollection {
                    {"code", "c1"},
                    {"state", "s1" }
                }, Stream.Null, null);
                var mockAuthService = MockAuthService(request);
                using (new HttpResultsFilter
                {
                    StringResult = @"{
                          ""access_token"": ""t1"",
                          ""token_type"": ""Bearer"",
                          ""id_token"": ""eyJ0eXAiOiJKV1QiLCJhbGciOiJub25lIn0.eyJhdWQiOiIyZDRkMTFhMi1mODE0LTQ2YTctODkwYS0yNzRhNzJhNzMwOWUiLCJpc3MiOiJodHRwczovL3N0cy53aW5kb3dzLm5ldC83ZmU4MTQ0Ny1kYTU3LTQzODUtYmVjYi02ZGU1N2YyMTQ3N2UvIiwiaWF0IjoxMzg4NDQwODYzLCJuYmYiOjEzODg0NDA4NjMsImV4cCI6MTM4ODQ0NDc2MywidmVyIjoiMS4wIiwidGlkIjoiN2ZlODE0NDctZGE1Ny00Mzg1LWJlY2ItNmRlNTdmMjE0NzdlIiwib2lkIjoiNjgzODlhZTItNjJmYS00YjE4LTkxZmUtNTNkZDEwOWQ3NGY1IiwidXBuIjoiZnJhbmttQGNvbnRvc28uY29tIiwidW5pcXVlX25hbWUiOiJmcmFua21AY29udG9zby5jb20iLCJzdWIiOiJKV3ZZZENXUGhobHBTMVpzZjd5WVV4U2hVd3RVbTV5elBtd18talgzZkhZIiwiZmFtaWx5X25hbWUiOiJNaWxsZXIiLCJnaXZlbl9uYW1lIjoiRnJhbmsifQ.""
                        }"
                })
                {
                    var session = new AuthUserSession { State = "s1" };

                    Subject.Authenticate(mockAuthService.Object, session, new Authenticate());

                    var tokens = session.GetOAuthTokens("aad");
                    var items = tokens.Items;
                    items["token_type"].Should().Be("Bearer");
                    items["iss"].Should().Be("https://sts.windows.net/7fe81447-da57-4385-becb-6de57f21477e/");
                    items["sub"].Should().Be("JWvYdCWPhhlpS1Zsf7yYUxShUwtUm5yzPmw_-jX3fHY");
                }
            }
        }
开发者ID:jfoshee,项目名称:ServiceStack.Authentication.Aad,代码行数:32,代码来源:AadAuthProviderTest.cs


示例18: RegisterAndLogin

        protected AuthUserSession RegisterAndLogin(IUserAuthRepository userAuthRepository, AuthUserSession oAuthUserSession)
		{
			Register(userAuthRepository, oAuthUserSession);

			Login(RegisterDto.UserName, RegisterDto.Password, oAuthUserSession);

			oAuthUserSession = requestContext.ReloadSession();
			return oAuthUserSession;
		}
开发者ID:nustack,项目名称:ServiceStack,代码行数:9,代码来源:OAuthUserSessionTestsBase.cs


示例19: LoadUserAuthInfo

        protected override void LoadUserAuthInfo(AuthUserSession userSession, IAuthTokens tokens, Dictionary<string, string> authInfo)
        {
            if (authInfo.ContainsKey("user_id"))
                tokens.UserId = authInfo.GetValueOrDefault("user_id");

            if (authInfo.ContainsKey("name"))
                tokens.DisplayName = authInfo.GetValueOrDefault("name");

            if (authInfo.ContainsKey("FullName"))
            {
                tokens.FullName = authInfo.GetValueOrDefault("FullName");
                if (tokens.DisplayName.IsNullOrEmpty())
                    tokens.DisplayName = tokens.FullName;
            }

            if (authInfo.ContainsKey("Email"))
                tokens.Email = authInfo.GetValueOrDefault("Email");

            if (authInfo.ContainsKey("BirthDate"))
                tokens.BirthDate = authInfo.GetValueOrDefault("BirthDate").FromJsv<DateTime?>();

            if (authInfo.ContainsKey("BirthDateRaw"))
                tokens.BirthDateRaw = authInfo.GetValueOrDefault("BirthDateRaw");

            if (authInfo.ContainsKey("Country"))
                tokens.Country = authInfo.GetValueOrDefault("Country");

            if (authInfo.ContainsKey("Culture"))
                tokens.Culture = authInfo.GetValueOrDefault("Culture");

            if (authInfo.ContainsKey("Gender"))
                tokens.Gender = authInfo.GetValueOrDefault("Gender");

            if (authInfo.ContainsKey("MailAddress"))
                tokens.MailAddress = authInfo.GetValueOrDefault("MailAddress");

            if (authInfo.ContainsKey("Nickname"))
                tokens.Nickname = authInfo.GetValueOrDefault("Nickname");

            if (authInfo.ContainsKey("PostalCode"))
                tokens.PostalCode = authInfo.GetValueOrDefault("PostalCode");

            if (authInfo.ContainsKey("TimeZone"))
                tokens.TimeZone = authInfo.GetValueOrDefault("TimeZone");

            LoadUserOAuthProvider(userSession, tokens);
        }
开发者ID:rjdudley,项目名称:ServiceStack,代码行数:47,代码来源:OpenIdOAuthProvider.cs


示例20: Login

		protected object Login(string userName, string password, AuthUserSession oAuthUserSession = null)
		{
			if (oAuthUserSession == null)
				oAuthUserSession = requestContext.ReloadSession();

			var credentialsAuth = GetCredentialsAuthConfig();
			return credentialsAuth.Authenticate(service, oAuthUserSession,
				new Authenticate {
					provider = CredentialsAuthProvider.Name,
					UserName = RegisterDto.UserName,
					Password = RegisterDto.Password,
				});
		}
开发者ID:nustack,项目名称:ServiceStack,代码行数:13,代码来源:OAuthUserSessionTestsBase.cs



注:本文中的ServiceStack.Auth.AuthUserSession类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# OrmLite.OrmLiteConnectionFactory类代码示例发布时间:2022-05-26
下一篇:
C# AppObjects.Identification类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap