public MainViewModel(IEventAggregator eventAggregator, ISignalRClient signalRClient, IAuthStore authStore, IProductsRepository productsRepository) { this.eventAggregator = eventAggregator; this.signalRClient = signalRClient; this.productsRepository = productsRepository; deleteRequest = new InteractionRequest<Confirmation>(); CreateProductCommand = new DelegateCommand(CreateProduct); OpenProductCommand = new DelegateCommand<Product>(EditProduct); changePriceCommand = new DelegateCommand(ChangePrice, HasSelectedProducts); deleteCommand = new DelegateCommand(PromtDelete, HasSelectedProducts); cvs = new CollectionViewSource(); items = new ObservableCollection<Product>(); cvs.Source = items; cvs.SortDescriptions.Add(new SortDescription("Name", ListSortDirection.Ascending)); cvs.SortDescriptions.Add(new SortDescription("Size", ListSortDirection.Ascending)); var token = authStore.LoadToken(); if (token != null) { IsEditor = token.IsEditor(); IsAdmin = token.IsAdmin(); } }
public BearerHttpClient(IAuthStore authStore, IApplicationSettings settings) { BaseAddress = new Uri(settings.Endpoint, UriKind.Absolute); var token = authStore.LoadToken(); DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(Bearer, token.AccessToken); }
public FilesViewModel(IFilesRepository filesRepository, IAuthStore authStore, IProductsRepository productsRepository, Func<CreateFileViewModel> createFactory, Func<EditFileViewModel> editFactory) { this.filesRepository = filesRepository; this.productsRepository = productsRepository; this.createFactory = createFactory; this.editFactory = editFactory; var token = authStore.LoadToken(); if (token != null) { IsEditor = token.IsEditor(); IsAdmin = token.IsAdmin(); } cvs = new CollectionViewSource(); items = new ObservableCollection<FileDescription>(); cvs.Source = items; cvs.SortDescriptions.Add(new SortDescription("Name", ListSortDirection.Ascending)); cvs.SortDescriptions.Add(new SortDescription("Id", ListSortDirection.Ascending)); editRequest = new InteractionRequest<IConfirmation>(); BrowseCommand = new DelegateCommand(Browse); EditCommand = new DelegateCommand<FileDescription>(Edit); deleteCommand = new DelegateCommand(PromtDelete, HasSelectedItems); deleteRequest = new InteractionRequest<Confirmation>(); }
/// <summary> /// Initialize the podio class with Client ID and Client Secret /// <para>You can get the Client ID and Client Secret from here: https://developers.podio.com/api-key </para> /// </summary> /// <param name="clientId">Client ID</param> /// <param name="clientSecret">Client Secret</param> /// <param name="authStore"> /// If you need to persist the access tokens for a longer period (in your session, database or whereever), Implement /// PodioAPI.Utils.IAuthStore Interface and pass it in. /// <para> You can use the IsAuthenticated method to check if there is a stored access token already present</para> /// </param> public Podio(string clientId, string clientSecret, IAuthStore authStore = null) { ClientId = clientId; ClientSecret = clientSecret; ApiUrl = "https://api.podio.com:443"; AuthStore = authStore ?? new NullAuthStore(); }
public ProductEditViewModel(IProductsRepository repository, IEventAggregator eventAggregator, IAuthStore authStore, AttachmentsViewModel attachmentsViewModel) { this.repository = repository; this.eventAggregator = eventAggregator; this.authStore = authStore; this.attachmentsViewModel = attachmentsViewModel; SaveCommand = new DelegateCommand<ChildWindow>(Save); TabLoadedCommand = new DelegateCommand<object>(OnTabLoaded); }
public ShellViewModel(IAuthStore authStore, IAuthService authService, ISignalRClient signalRClient, Func<LoginViewModel> loginFactory, Func<LoggedInViewModel> loggedInFactory) { this.authStore = authStore; this.authService = authService; this.signalRClient = signalRClient; this.loginFactory = loginFactory; this.loggedInFactory = loggedInFactory; Refresh(); }
public PixivOAuthHandler(string loginHost, string oAuth2TokenPath, PixivOAuthRequest request, IAuthStore authStore, IHttpClientProvider httpClientProvider) { var factory = new EasyHttpClientFactory(); factory.Config.HttpClientProvider = httpClientProvider; this._request = request; this._oAuth2TokenPath = oAuth2TokenPath.Trim('/'); this._oAuth2Api = factory.Create <IOAuth2Api>(loginHost); this._authStore = authStore; }
public PermissionService( IPermissionRepository permissionRepository, IRoleRepository roleRepository, IAuthStore authStore, ICacheManager cacheManager ) { _permissionRepository = permissionRepository; _roleRepository = roleRepository; _authStore = authStore; _cacheManager = cacheManager; }
public TopMenuViewModel(IAuthStore authStore, INavigationService navigationService, IRegionManager regionManager, ISignalRClient signalRClient) { this.authStore = authStore; this.navigationService = navigationService; this.regionManager = regionManager; this.signalRClient = signalRClient; LogoutCommand = new DelegateCommand(Logout); NavigateToPageCommand = new DelegateCommand<string>(NavigateToPage); }
public ServerConnectionHandler(ILogger <ServerConnectionHandler> logger, IPackageParser packageParser, IUserRepository UserRepo, ICharacterRepositiory CharacterRepo, IAuthStore authStore) { this.logger = logger; this.packageParser = packageParser; this.UserRepo = UserRepo; this.CharacterRepo = CharacterRepo; this.authStore = authStore; }
public SettingsViewModel(IAuthStore authStore, IUsersRepository usersRepository) { this.usersRepository = usersRepository; SaveCommand = new DelegateCommand(Save); var token = authStore.LoadToken(); if (token != null && token.IsAuthenticated()) { UserName = token.UserName; Role = token.Role; } }
public ResourceGuruClient(string clientId, string clientSecret, IAuthStore authStore = null, WebProxy proxy = null) { Proxy = proxy; ClientId = clientId; ClientSecret = clientSecret; if (authStore != null) { AuthStore = authStore; } else { AuthStore = new NullAuthStore(); } OAuthInfo = AuthStore.Get(); }
//private readonly AttachmentsViewModel attachmentsViewModel; public ProductEditWindowViewModel(IProductsRepository repository, IEventAggregator eventAggregator, IAuthStore authStore/*, AttachmentsViewModel attachmentsViewModel*/) { this.repository = repository; this.eventAggregator = eventAggregator; //this.attachmentsViewModel = attachmentsViewModel; var token = authStore.LoadToken(); if (token != null) { canSave = token.IsEditor(); canEditPrice = token.IsAdmin(); } SaveCommand = new DelegateCommand(Save, () => canSave); CancelCommand = new DelegateCommand(() => IsWindowOpen = false); }
/// <summary> /// Internals the constructor. /// </summary> /// <param name="clientId">The client identifier.</param> /// <param name="clientSecret">The client secret.</param> /// <param name="authStore">The authentication store.</param> private void internalConstructor(string clientId, string clientSecret, IAuthStore authStore) { ClientId = clientId; ClientSecret = clientSecret; ApiUrl = "https://api.podio.com:443"; if (authStore != null) { AuthStore = authStore; } else { AuthStore = new NullAuthStore(); } OAuth = AuthStore.Get(); }
public SettingsViewModel(IAuthStore authStore, Func<ChangePasswordViewModel> changePasswordFactory) { this.changePasswordFactory = changePasswordFactory; var v = Assembly.GetEntryAssembly().GetName().Version; Version = (v.Build > 0) ? string.Join(".", new[] { v.Major, v.Minor, v.Build }) : string.Join(".", new[] { v.Major, v.Minor }); changePasswordRequest = new InteractionRequest<IConfirmation>(); ChangePasswordCommand = new DelegateCommand(ChangePassword); var token = authStore.LoadToken(); if (token != null && token.IsAuthenticated()) { UserName = token.UserName; Role = token.Role; } }
/// <summary> /// Initialize the podio class with Client ID and Client Secret /// <para>You can get the Client ID and Client Secret from here: https://developers.podio.com/api-key </para> /// </summary> /// <param name="clientId">The client identifier.</param> /// <param name="clientSecret">The client secret.</param> /// <param name="authStore">The authentication store.</param> public Podio(string clientId, string clientSecret, IAuthStore authStore = null) { internalConstructor(clientId, clientSecret, authStore); }
public PixivOAuthHandler(string loginHost, PixivOAuthRequest request, IAuthStore authStore, IHttpClientProvider httpClientProvider) : this(loginHost, "auth/token", request, authStore, httpClientProvider) { }
public ProductsRepository(IAuthStore authStore) { this.authStore = authStore; }
public FilesRepository(IAuthStore authStore) { this.authStore = authStore; }
public AuthController(IAuthStore authStore) { this.AuthStore = authStore; }
public AuthenticationService(IAuthStore authStore) { _authStore = authStore; }
protected override async Task <HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) { if (_responseStore == null) { _responseStore = AuthAPIConfiguration.Instance.ResponseStore; } if (_authStore == null) { _authStore = AuthAPIConfiguration.Instance.AuthStore; } var authHeader = new AuthHeader(request.Headers.Authorization == null ? string.Empty : request.Headers.Authorization.Parameter); if (authHeader.IsValid) { var clientSecret = await _authStore.GetClientSecretById(authHeader.Request.ClientId); var userPassword = await _authStore.GetPasswordByUserName(authHeader.Request.UserName); var cachedResponseIdentifier = await _responseStore.GetResponse(authHeader.Request.Identifier); if (cachedResponseIdentifier != null) { var expectedRequestPayload = authHeader.Request.Copy <RequestPayload>(); expectedRequestPayload.RequestCount = string.Format("{0:D8}", int.Parse(cachedResponseIdentifier.Response.RequestCount) + 1); var content = await request.Content.ReadAsByteArrayAsync(); var contentString = System.Text.Encoding.UTF8.GetString(content); var expectedAuthHeader = new AuthHeader { Request = expectedRequestPayload, Data = new DataPayload { ClientId = authHeader.Request.ClientId, Method = request.Method.Method, Password = userPassword, RequestBodyBase64 = Convert.ToBase64String(content), RequestURI = request.RequestUri.PathAndQuery, UserName = authHeader.Request.UserName } }; if (expectedAuthHeader.ToHMAC(clientSecret).Equals(request.Headers.Authorization.Parameter.Split(':')[1])) { var newResponse = authHeader.Request.ToResponsePayload(); await _responseStore.UpdateResponse(newResponse.Identifier, newResponse); request.GetRequestContext().Principal = new GenericPrincipal(new GenericIdentity(authHeader.Request.UserName), new string[] { }); } } } return(await base.SendAsync(request, cancellationToken) .ContinueWith(task => { var response = task.Result; if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized) { var responsePayload = new ResponsePayload { Identifier = Guid.NewGuid().ToString(), RequestCount = string.Format("{0:D8}", 0) }; response.Headers.WwwAuthenticate.Add(new AuthenticationHeaderValue("AuthAPI", responsePayload.ToBase64())); _responseStore.StoreResponse(responsePayload, DateTime.Now.AddMilliseconds(AuthAPIConfiguration.Instance.TokenExpirationMiliseconds)); } return response; })); }
public AuthService(IAuthStore store) { this.store = store; }
public AuthService(IAuthStore store, IApplicationSettings settings) { this.store = store; this.settings = settings; }
public UsersRepository(IAuthStore authStore) { this.authStore = authStore; }
public ApiClient(IAuthStore authStore, IApiSettings apiSettings) { _authStore = authStore; _apiSettings = apiSettings; }