Skip to content

Conversation

@shuffle-c
Copy link
Collaborator

Main changes:

  • WinHelloProvider isn't a singleton, performs lazy checks for availability
  • KeyManager always exists
  • Single entry for handling auth exceptions
@shuffle-c shuffle-c requested a review from sirAndros August 27, 2021 11:58
public static IAuthProvider GetInstance(IntPtr keePassWindowHandle, AuthCacheType authCacheType)
public static IAuthProvider Create(IntPtr keePassWindowHandle)
{
var authCacheType = Settings.Instance.GetAuthCacheType();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не очень нравится что тут зависимость на настройки. Всё-таки кажется что раз метод статический, то хочется чтобы он был чистым.
Но, с другой стороны, тут так же есть UAC и мы жили с этим без напрягов

byte[] PromptToDecrypt(byte[] data);
void ClaimCurrentCacheType(AuthCacheType authCacheType);
AuthCacheType CurrentCacheType { get; }
AuthCacheType CurrentCacheType { get; set; }
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Наличие сеттера вводит в заблужение о цели существования ClaimCurrentCacheType

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Наверное, просто Claim... не должен быть частью AuthProviderа

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ещё надо подумать – можно ли как-то обойтись от зависимости на тип кэша у провайдера совсем. Например, этот же энам у нас используется и при создании storage'а, но там мы на разные реализации всё разнесли и свитч только в фабрике присутствует. Может и тут нам также поступить и декомпозировать ответственность за шифровку/дешивровку в отдельный класс, а за выбор ключа сделать ответственным кого-нибудь другого? Можно передавать провайдер ключа как зависимость AuthProvider'у, например. Что думаешь?

{
CreatePersistentKey(false).Dispose();
}
CreatePersistentKey(false).Dispose();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Раз уж тронули, добавь плиз overwriteExisting:

{
SetCompositeKey(keyPromptForm, compositeKey);
CloseFormWithResult(keyPromptForm, DialogResult.OK);
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

else { Debug.Assert(); }
{
if (_keyCipher.AuthProvider.CurrentCacheType != Settings.Instance.GetAuthCacheType())
{
// todo: something unexpected, messagebox
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Наверное тут такая же ситуация, как и если у нас исключение "ключ был удалён" и надо то же сообщение показывать

}
else if (SystemInformation.TerminalServerSession) // RDP
{
MessageBox.Show(AuthProviderUIContext.Current,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А для этого не требуется AuthProviderUIContext? Там выше у нас зачем-то юзинг перед сообщениями

{
ErrorHandler.ShowError(ex);
}
_keyManager.RevokeAll();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Раз мы везде убрали проверки внутри, то надо сделать проверку на null в конструкторе

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants