public static IdentityServerServiceFactory Create( string connectionStringName, string issuerUri, string siteName, string publicHostAddress = "") { var users = new[] { new InMemoryUser { Subject = "818727", Username = "******", Password = "******", Claims = new [] { new Claim(Constants.ClaimTypes.GivenName, "Alice"), new Claim(Constants.ClaimTypes.FamilyName, "Smith"), new Claim(Constants.ClaimTypes.Email, "*****@*****.**") } }, new InMemoryUser { Subject = "88421113", Username = "******", Password = "******", Claims = new [] { new Claim(Constants.ClaimTypes.GivenName, "Bob"), new Claim(Constants.ClaimTypes.FamilyName, "Smith"), new Claim(Constants.ClaimTypes.Email, "*****@*****.**") } } }; var settings = new LocalTestCoreSettings(issuerUri, siteName, publicHostAddress); var userSvc = new InMemoryUserService(users); var efServiceFactory = new Core.EntityFramework.ServiceFactory("name=" + connectionStringName); efServiceFactory.ConfigureClients(LocalTestClients.Get()); efServiceFactory.ConfigureScopes(LocalTestScopes.Get()); // if we're going to use a database to store our tokens, we'll need to clean up at some point ExpiredTokenCollector.Start("name=" + connectionStringName, 5); var fact = new IdentityServerServiceFactory { CoreSettings = Registration.RegisterFactory <CoreSettings>(() => settings), UserService = Registration.RegisterFactory <IUserService>(() => userSvc), ScopeService = Registration.RegisterFactory <IScopeService>(efServiceFactory.CreateScopeService), ClientService = Registration.RegisterFactory <IClientService>(efServiceFactory.CreateClientService), ConsentService = Registration.RegisterFactory <IConsentService>(efServiceFactory.CreateConsentService), AuthorizationCodeStore = Registration.RegisterFactory <IAuthorizationCodeStore>(efServiceFactory.CreateAuthorizationCodeStore), TokenHandleStore = Registration.RegisterFactory <ITokenHandleStore>(efServiceFactory.CreateTokenHandleStore), RefreshTokenStore = Registration.RegisterFactory <IRefreshTokenStore>(efServiceFactory.CreateRefreshTokenStore) }; return(fact); }
public static IdentityServerServiceFactory Create( string issuerUri, string siteName, string publicHostAddress = "") { var settings = new LocalTestCoreSettings(issuerUri, siteName, publicHostAddress); var codeStore = new InMemoryAuthorizationCodeStore(); var tokenStore = new InMemoryTokenHandleStore(); var consent = new InMemoryConsentService(); var scopes = new InMemoryScopeService(LocalTestScopes.Get()); var clients = new InMemoryClientService(LocalTestClients.Get()); var logger = new TraceLogger(); var users = new InMemoryUser[] { new InMemoryUser { Subject = "alice", Username = "******", Password = "******", Claims = new Claim[] { new Claim(Constants.ClaimTypes.GivenName, "Alice"), new Claim(Constants.ClaimTypes.FamilyName, "Smith"), new Claim(Constants.ClaimTypes.Email, "*****@*****.**"), } }, new InMemoryUser { Subject = "bob", Username = "******", Password = "******", Claims = new Claim[] { new Claim(Constants.ClaimTypes.GivenName, "Bob"), new Claim(Constants.ClaimTypes.FamilyName, "Smith"), new Claim(Constants.ClaimTypes.Email, "*****@*****.**"), } }, }; var userSvc = new InMemoryUserService(users); var fact = new IdentityServerServiceFactory { Logger = () => logger, UserService = () => userSvc, AuthorizationCodeStore = () => codeStore, TokenHandleStore = () => tokenStore, CoreSettings = () => settings, ConsentService = () => consent, ScopeService = () => scopes, ClientService = () => clients }; return(fact); }
public static IdentityServerServiceFactory Create( string issuerUri, string siteName, string publicHostAddress = "") { var users = new [] { new InMemoryUser { Subject = "818727", Username = "******", Password = "******", Claims = new [] { new Claim(Constants.ClaimTypes.GivenName, "Alice"), new Claim(Constants.ClaimTypes.FamilyName, "Smith"), new Claim(Constants.ClaimTypes.Email, "*****@*****.**") } }, new InMemoryUser { Subject = "88421113", Username = "******", Password = "******", Claims = new [] { new Claim(Constants.ClaimTypes.GivenName, "Bob"), new Claim(Constants.ClaimTypes.FamilyName, "Smith"), new Claim(Constants.ClaimTypes.Email, "*****@*****.**") } } }; var settings = new LocalTestCoreSettings(issuerUri, siteName, publicHostAddress); var scopes = new InMemoryScopeService(LocalTestScopes.Get()); var clients = new InMemoryClientService(LocalTestClients.Get()); var userSvc = new InMemoryUserService(users); var fact = new IdentityServerServiceFactory { UserService = Registration.RegisterFactory <IUserService>(() => userSvc), CoreSettings = Registration.RegisterFactory <CoreSettings>(() => settings), ScopeService = Registration.RegisterFactory <IScopeService>(() => scopes), ClientService = Registration.RegisterFactory <IClientService>(() => clients) }; return(fact); }