コード例 #1
0
        private static TokenResponse GetAuthCode(Client client, UserResultBase user)
        {
            var state       = $"{Guid.NewGuid()}";
            var scopes      = Scopes.GetScopes();
            var redirectUrl = Configuration["RedirectUrl"];
            var url         = client.GetAuthorizatoinEndpoint(state, redirectUrl, scopes);

            Console.WriteLine();
            Console.WriteLine("Navigate to the link below, and login using the following credentials:");
            Console.WriteLine($"\t{url}");
            Console.WriteLine($"\tID:       {user.UserId}");
            Console.WriteLine($"\tPassword: {user.Password}");

            Console.WriteLine();
            Console.WriteLine($"Paste in the '{redirectUrl}' address that you were redirected to:");
            var redirectedTo = Console.ReadLine();

            Console.WriteLine();
            Console.Write("Validating...");
            var resp = client.HandleEndpointResult(redirectedTo, state);

            Console.WriteLine(" done");

            return(resp);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: tipstrade/TipsTrade-HMRC
        private static TokenResponse GetAuthCode(Client client, UserResultBase user)
        {
            var state       = $"{Guid.NewGuid()}";
            var scopes      = Scopes.GetScopes();
            var redirectUrl = Configuration["RedirectUrl"];
            var url         = client.GetAuthorizatoinEndpoint(state, redirectUrl, scopes);

            try {
                OpenUrl(url);
            } catch (Exception e) {
                Console.WriteLine();
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine($"Couldn't launch the Login URI. {e.Message}");
                Console.ResetColor();
            }

            Console.WriteLine();
            Console.WriteLine("Navigate to the link below, and login using the following credentials:");
            Console.WriteLine($"\t{url}");
            Console.WriteLine($"\tID:       {user.UserId}");
            Console.WriteLine($"\tPassword: {user.Password}");

            Console.WriteLine();
            Console.WriteLine($"Paste in the '{redirectUrl}' address that you were redirected to:");
            var redirectedTo = Console.ReadLine();

            Console.WriteLine();
            Console.Write("Validating...");
            var resp = client.HandleEndpointResult(redirectedTo, state);

            Console.WriteLine(" done");

            return(resp);
        }
コード例 #3
0
        public void TestVat()
        {
            var scopes = Scopes.GetScopes <Api.Vat.VatApi>();

            Assert.Equal(2, scopes.Count());
            Assert.Contains(scopes, s => Scopes.VATRead.Equals(s));
            Assert.Contains(scopes, s => Scopes.VATWrite.Equals(s));
        }
コード例 #4
0
        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddDeveloperIdentityServer()
            .AddInMemoryScopes(Scopes.GetScopes())
            .AddInMemoryClients(Clients.GetClients());

            services.AddTransient <IResourceOwnerPasswordValidator, ResourceOwnerPasswordValidator>();
            services.AddTransient <IProfileService, ProfileService>();
        }
コード例 #5
0
ファイル: Startup.cs プロジェクト: MeetCodes/identityServer
        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc();

            services.AddIdentityServer()
            .AddInMemoryClients(Clients.GetClients())
            .AddInMemoryScopes(Scopes.GetScopes())
            .AddInMemoryStores()
            .AddInMemoryUsers(Users.Get())
            .SetTemporarySigningCredential();;
        }
コード例 #6
0
    public void ConfigureServices(IServiceCollection services)
    {
        var builder = services.AddIdentityServer(options =>
        {
            options.IssuerUri = "https://idsvr4";
            options.Endpoints.EnableAuthorizeEndpoint = false;
            options.KeyManagement.Enabled             = false;
        });

        builder.AddInMemoryClients(Clients.Get());
        builder.AddInMemoryApiResources(Scopes.GetApis());
        builder.AddInMemoryApiScopes(Scopes.GetScopes());
        builder.AddTestUsers(Users.Get());
        builder.AddDeveloperSigningCredential(persistKey: false);
    }
コード例 #7
0
ファイル: Startup.cs プロジェクト: gauravhrana/web-api
        public void Configuration(IAppBuilder app)
        {
            var factory = new IdentityServerServiceFactory()
                          .UseInMemoryUsers(Users.GetUsers())
                          .UseInMemoryClients(Clients.GetClients())
                          .UseInMemoryScopes(Scopes.GetScopes());

            var options = new IdentityServerOptions
            {
                SigningCertificate    = new X509Certificate2(Convert.FromBase64String(ConfigurationManager.AppSettings["SigningCertificate"]), ConfigurationManager.AppSettings["SigningCertificatePassword"]),
                Factory               = factory,
                RequireSsl            = false,
                AuthenticationOptions = new AuthenticationOptions {
                    EnablePostSignOutAutoRedirect = true
                }
            };

            app.UseIdentityServer(options);
        }
コード例 #8
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            // Add framework services.
            services.AddDbContext <ApplicationDbContext>(options =>
                                                         options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));

            services.AddIdentity <ApplicationUser, IdentityRole>()
            .AddEntityFrameworkStores <ApplicationDbContext>()
            .AddDefaultTokenProviders();

            services.AddMvc();

            // Add application services.
            services.AddTransient <IEmailSender, AuthMessageSender>();
            services.AddTransient <ISmsSender, AuthMessageSender>();

            // Adds IdentityServer
            services.AddDeveloperIdentityServer()
            .AddInMemoryScopes(Scopes.GetScopes())
            .AddInMemoryClients(Clients.GetClients())
            .AddAspNetIdentity <ApplicationUser>();
        }
コード例 #9
0
        public void TestHelloWorld()
        {
            var scopes = Scopes.GetScopes <Api.HelloWorld.HelloWorldApi>();

            Assert.Single(scopes);
        }
コード例 #10
0
        public void TestAllScopes()
        {
            var scopes = Scopes.GetScopes();

            Assert.NotEmpty(scopes);
        }