コード例 #1
0
        private static IOptionsSnapshot <IdentityServiceOptions> CreateOptions()
        {
            var identityServiceOptions = new IdentityServiceOptions();
            var optionsSetup           = new IdentityServiceOptionsDefaultSetup();

            optionsSetup.Configure(identityServiceOptions);

            SigningCredentials signingCredentials = new SigningCredentials(CryptoUtilities.CreateTestKey(), "RS256");

            identityServiceOptions.SigningKeys.Add(signingCredentials);
            identityServiceOptions.Issuer = "http://server.example.com";
            identityServiceOptions.IdTokenOptions.UserClaims.AddSingle(
                IdentityServiceClaimTypes.Subject,
                ClaimTypes.NameIdentifier);

            identityServiceOptions.RefreshTokenOptions.UserClaims.AddSingle(
                IdentityServiceClaimTypes.Subject,
                ClaimTypes.NameIdentifier);

            var mock = new Mock <IOptionsSnapshot <IdentityServiceOptions> >();

            mock.Setup(m => m.Value).Returns(identityServiceOptions);
            mock.Setup(m => m.Get(It.IsAny <string>())).Returns(identityServiceOptions);

            return(mock.Object);
        }
コード例 #2
0
        private IOptions <IdentityServiceOptions> GetOptions()
        {
            var IdentityServiceOptions = new IdentityServiceOptions();

            var optionsSetup = new IdentityServiceOptionsDefaultSetup();

            optionsSetup.Configure(IdentityServiceOptions);

            var mock = new Mock <IOptions <IdentityServiceOptions> >();

            mock.Setup(m => m.Value).Returns(IdentityServiceOptions);

            return(mock.Object);
        }
コード例 #3
0
        private IOptions <IdentityServiceOptions> GetOptions()
        {
            var IdentityServiceOptions = new IdentityServiceOptions()
            {
                Issuer = "http://www.example.com/issuer"
            };

            IdentityServiceOptions.SigningKeys.Add(new SigningCredentials(CryptoUtilities.CreateTestKey(), "RS256"));

            var optionsSetup = new IdentityServiceOptionsDefaultSetup();

            optionsSetup.Configure(IdentityServiceOptions);

            var mock = new Mock <IOptions <IdentityServiceOptions> >();

            mock.Setup(m => m.Value).Returns(IdentityServiceOptions);

            return(mock.Object);
        }
コード例 #4
0
        private IOptions <IdentityServiceOptions> GetOptions()
        {
            var identityServiceOptions = new IdentityServiceOptions()
            {
                Issuer = "http://www.example.com/issuer"
            };
            var optionsSetup = new IdentityServiceOptionsDefaultSetup();

            optionsSetup.Configure(identityServiceOptions);

            identityServiceOptions.SigningKeys.Add(new SigningCredentials(CryptoUtilities.CreateTestKey(), "RS256"));
            identityServiceOptions.IdTokenOptions.UserClaims.AddSingle("sub", ClaimTypes.NameIdentifier);

            var mock = new Mock <IOptions <IdentityServiceOptions> >();

            mock.Setup(m => m.Value).Returns(identityServiceOptions);

            return(mock.Object);
        }