internal OAuthServicesContext(IOAuthUserService userService,
                               IOAuthClientStore clientStore,
                               IOAuthRefreshTokenStore refreshTokenStore,
                               IOAuthTokenService tokenService)
 {
     UserService       = userService;
     ClientStore       = clientStore;
     RefreshTokenStore = refreshTokenStore;
     TokenService      = tokenService;
 }
        public TwitterController(IProvideUserConfiguration configuration, Func<TwitterLoginCommand> twitterLoginCommandAccessor, ITwitterClient twitterClient, IOAuthUserService service)
        {
            if (configuration == null)
                throw new ArgumentNullException("configuration");

            this.configuration = configuration;
            this.twitterLoginCommandAccessor = twitterLoginCommandAccessor;
            this.twitterClient = twitterClient;
            this.service = service;
        }
        public FoursquareController(IProvideUserConfiguration configuration, Func<FoursquareLoginCommand> foursquareLoginCommandAccessor, IThreeBytesTicketService ticketService, IFoursquareClient foursquareClient, IOAuthUserService service)
        {
            if (configuration == null)
                throw new ArgumentNullException("configuration");

            this.configuration = configuration;
            this.foursquareLoginCommandAccessor = foursquareLoginCommandAccessor;
            this.ticketService = ticketService;
            this.foursquareClient = foursquareClient;
            this.service = service;
        }
        public FacebookLoginCommand(IOAuthUserService service, IProvideUserConfiguration configuration, Func<RegisterExternalUserPreCommand> registerExternalUserPreCommandAccessor, Func<LinkExistingUserToExternalProviderPreCommand> linkExistingUserToExternalProviderPreCommandAccessor, IFacebookClient facebookClient)
        {
            if (service == null)
                throw new ArgumentNullException("service");

            if (configuration == null)
                throw new ArgumentNullException("configuration");

            this.service = service;
            this.configuration = configuration;
            this.registerExternalUserPreCommandAccessor = registerExternalUserPreCommandAccessor;
            this.linkExistingUserToExternalProviderPreCommandAccessor = linkExistingUserToExternalProviderPreCommandAccessor;
            this.facebookClient = facebookClient;
        }
        public TwitterLoginCommand(IOAuthUserService service, IProvideUserConfiguration configuration, Func<LinkExistingUserToExternalProviderPreCommand> linkExistingUserToExternalProviderPreCommandAccessor, ITwitterClient twitterClient, IProvideCurrentUserDetails currentUserDetails)
        {
            if (service == null)
                throw new ArgumentNullException("service");

            if (configuration == null)
                throw new ArgumentNullException("configuration");

            this.service = service;
            this.configuration = configuration;
            this.linkExistingUserToExternalProviderPreCommandAccessor = linkExistingUserToExternalProviderPreCommandAccessor;
            this.twitterClient = twitterClient;
            this.currentUserDetails = currentUserDetails;
        }
Beispiel #6
0
        public static bool ValidatePrincipal(ClaimsPrincipal principal, string targetRealm, IOAuthUserService userService)
        {
            // Make sure principal isn't null
            if (principal == null)
            {
                return(false);
            }

            // Make sure identity is authenticated
            if (!principal.Identity.IsAuthenticated)
            {
                return(false);
            }

            // Make sure principal belongs to realm
            var realm = principal.Claims.FirstOrDefault(x => x.Type == OAuth.ClaimTypes.Realm)?.Value;

            if (realm == null || realm != targetRealm)
            {
                return(false);
            }

            // Make sure username is present
            var username = principal.Claims.FirstOrDefault(x => x.Type == ClaimTypes.Name)?.Value;

            if (string.IsNullOrWhiteSpace(username))
            {
                return(false);
            }

            // Make sure username is valid
            if (!userService.ValidateUser(username))
            {
                return(false);
            }

            return(true);
        }
 public LinkExistingUserToExternalProviderPreCommand(IProvideUserConfiguration configuration, IOAuthUserService service, IOAuthUserValidatorResolver validatorResolver)
 {
     this.configuration = configuration;
     this.service = service;
     this.validatorResolver = validatorResolver;
 }