Advertisement
Guest User

Untitled

a guest
Dec 8th, 2016
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1. //Startup.cs (Auth c# project)
  2. public void Configuration(IAppBuilder app) {
  3. var inMemoryManager = new InMemoryManager();
  4. var factory = new IdentityServerServiceFactory()
  5. .UseInMemoryClients(inMemoryManager.GetClients())
  6. .UseInMemoryScopes(inMemoryManager.GetScopes())
  7. .UseInMemoryUsers(inMemoryManager.GetUsers());
  8.  
  9. var options = new IdentityServerOptions {
  10. Factory = factory,
  11. RequireSsl = false
  12. };
  13.  
  14. app.UseIdentityServer(options);
  15. }
  16.  
  17. //InMemoryManager.cs
  18. public class InMemoryManager {
  19. public List<InMemoryUser> GetUsers() {
  20. return new List<InMemoryUser> {
  21. new InMemoryUser {
  22. Username = "alice",
  23. Password = "password",
  24. Subject = "2",
  25. Claims = new [] {
  26. new Claim("User name", "Alice")
  27. }
  28. }
  29. };
  30. }
  31.  
  32. public IEnumerable<Scope> GetScopes() {
  33. return new[] {
  34. new Scope {
  35. Name = "api1",
  36. DisplayName = "API 1"
  37. }
  38. };
  39. }
  40.  
  41. public IEnumerable<Client> GetClients() {
  42. return new[] {
  43. new Client {
  44. ClientName = "Silicon on behalf of Carbon Client",
  45. ClientId = "carbon",
  46. Enabled = true,
  47. //AccessTokenType = AccessTokenType.Reference,
  48.  
  49. Flow = Flows.ResourceOwner,
  50.  
  51. ClientSecrets = new List<Secret> {
  52. new Secret("secret".Sha256())
  53. },
  54.  
  55. AllowedScopes = new List<string> {
  56. "api1"
  57. }
  58. }
  59. };
  60. }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement