public AuthenticationRegistry(IAuthenticationProvider facebookProvider, IAuthenticationProvider googleProvider, IAuthenticationProvider twitterProvider) { var authenticationService = new AuthenticationService(); if (facebookProvider != null) { authenticationService.AddProvider(facebookProvider); } if (googleProvider != null) { authenticationService.AddProvider(googleProvider); } if (twitterProvider != null) { authenticationService.AddProvider(twitterProvider); } For<IAuthenticationService>() .Use(authenticationService); For<IAntiForgery>() .Use<AntiForgery>(); }
public void GivenAnExistingProvider_AddProvider_ThrowsAnException() { // Arrange. var authenticationService = new AuthenticationService(); var facebookProvider = new FacebookProvider("a", "b", new Uri("http://www.google.com")); // Act. authenticationService.AddProvider(facebookProvider); var result = Assert.Throws<AuthenticationException>( () => authenticationService.AddProvider(facebookProvider)); // Assert. Assert.NotNull(result); Assert.Equal("Trying to add a facebook provider, but one already exists.", result.Message); }
public AccountController(IUserRepository userRepository, IFormsAuthentication formsAuthentication, ITracer tracer, IDietRepository dietRepository) { _userRepository = userRepository; _formsAuthentication = formsAuthentication; _tracer = tracer; _dietRepository = dietRepository; var facebookProvider = new FacebookProvider(FacebookAppId, FacebookAppSecret); var twitterProvider = new TwitterProvider(TwitterConsumerKey, TwitterConsumerSecret); var googleProvider = new GoogleProvider(GoogleConsumerKey, GoogleConsumerSecret); _authenticationService = new AuthenticationService(); _authenticationService.AddProvider(facebookProvider); _authenticationService.AddProvider(twitterProvider); _authenticationService.AddProvider(googleProvider); }
public HomeController() { var facebookProvider = new FacebookProvider(FacebookAppId, FacebookAppSecret, new Uri( "http://localhost:1337/home/AuthenticateCallback?providerKey=facebook")); var twitterProvider = new TwitterProvider(TwitterConsumerKey, TwitterConsumerSecret, new Uri( "http://localhost:1337/home/AuthenticateCallback?providerKey=twitter")); var googleProvider = new GoogleProvider(GoogleConsumerKey, GoogleConsumerSecret, new Uri( "http://localhost:1337/home/AuthenticateCallback?providerKey=google")); _authenticationService = new AuthenticationService(); _authenticationService.AddProvider(facebookProvider); _authenticationService.AddProvider(twitterProvider); _authenticationService.AddProvider(googleProvider); }
protected override void ConfigureApplicationContainer(TinyIoCContainer container) { base.ConfigureApplicationContainer(container); var githubProvider = new GitHubProvider(new ProviderParams() { Key = GithubConsumerKey, Secret = GithubConsumerSecret }); var authenticationService = new AuthenticationService(); authenticationService.AddProvider(githubProvider); container.Register<IAuthenticationService>(authenticationService); }
public void GivenAValidProviderKey_RedirectToAuthenticate_ReturnsAUri() { // Arrange. var authenticationService = new AuthenticationService(); authenticationService.AddProvider(new FacebookProvider("aa", "bb", new Uri("http://www.google.com"))); // Act. var result = authenticationService.RedirectToAuthenticationProvider("Facebook", "abc"); // Assert. Assert.NotNull(result); Assert.Equal(result.AbsoluteUri, "https://www.facebook.com/dialog/oauth?client_id=aa&redirect_uri=http://www.google.com/&state=abc"); }
private static void RegisterAuthenticationProviders(TinyIoCContainer container) { Condition.Requires(container).IsNotNull(); var twitterProvider = new TwitterProvider(TwitterConsumerKey, TwitterConsumerSecret, new Uri( "http://localhost:6969/AuthenticateCallback?providerKey=Twitter")); var facebookProvider = new FacebookProvider(FacebookAppId, FacebookAppSecret, new Uri( "http://localhost:6969/AuthenticateCallback?providerKey=facebook")); var googleProvider = new GoogleProvider(GoogleConsumerKey, GoogleConsumerSecret, new Uri( "http://localhost:6969/AuthenticateCallback?providerKey=google")); var authenticationService = new AuthenticationService(); authenticationService.AddProvider(twitterProvider); authenticationService.AddProvider(facebookProvider); authenticationService.AddProvider(googleProvider); container.Register<IAuthenticationService>(authenticationService); }
public void GivenANewProvider_AddProvider_AddsTheProviderToTheProviderCollection() { // Arrange. var authenticationService = new AuthenticationService(); // Act. authenticationService.AddProvider(new FacebookProvider("a", "b", new Uri("http://www.google.com"))); // Assert. var providers = authenticationService.AuthenticationProviders; Assert.NotNull(providers); Assert.Equal(1, providers.Count); Assert.NotNull(providers["facebook"]); }
protected override void ConfigureApplicationContainer(TinyIoCContainer container) { base.ConfigureApplicationContainer(container); var githubProvider = new GitHubProvider(new ProviderParams() { Key = GithubConsumerKey, Secret = GithubConsumerSecret }); ((WorldDomination.Web.Authentication.ExtraProviders.GitHub.GitHubAuthenticationServiceSettings) githubProvider.DefaultAuthenticationServiceSettings).Scope = "user:email,public_repo"; var authenticationService = new AuthenticationService(); authenticationService.AddProvider(githubProvider); container.Register<IAuthenticationService>(authenticationService); }