Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Startup.cs (Auth c# project)
- public void Configuration(IAppBuilder app) {
- var inMemoryManager = new InMemoryManager();
- var factory = new IdentityServerServiceFactory()
- .UseInMemoryClients(inMemoryManager.GetClients())
- .UseInMemoryScopes(inMemoryManager.GetScopes())
- .UseInMemoryUsers(inMemoryManager.GetUsers());
- var options = new IdentityServerOptions {
- Factory = factory,
- RequireSsl = false
- };
- app.UseIdentityServer(options);
- }
- //InMemoryManager.cs
- public class InMemoryManager {
- public List<InMemoryUser> GetUsers() {
- return new List<InMemoryUser> {
- new InMemoryUser {
- Username = "alice",
- Password = "password",
- Subject = "2",
- Claims = new [] {
- new Claim("User name", "Alice")
- }
- }
- };
- }
- public IEnumerable<Scope> GetScopes() {
- return new[] {
- new Scope {
- Name = "api1",
- DisplayName = "API 1"
- }
- };
- }
- public IEnumerable<Client> GetClients() {
- return new[] {
- new Client {
- ClientName = "Silicon on behalf of Carbon Client",
- ClientId = "carbon",
- Enabled = true,
- //AccessTokenType = AccessTokenType.Reference,
- Flow = Flows.ResourceOwner,
- ClientSecrets = new List<Secret> {
- new Secret("secret".Sha256())
- },
- AllowedScopes = new List<string> {
- "api1"
- }
- }
- };
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement