diff --git a/locale/ubl-settings-usergroups.pot b/locale/ubl-settings-usergroups.pot index 1f11d21..cec9580 100644 --- a/locale/ubl-settings-usergroups.pot +++ b/locale/ubl-settings-usergroups.pot @@ -1058,4 +1058,8 @@ msgstr "" #: source/ubl-strings.h:302 msgid "The login rules are not followed" +msgstr "" + +#: source/ubl-strings.h:302 +msgid "The password does not meet the password policy requirements" msgstr "" \ No newline at end of file diff --git a/locale/ubl-settings-usergroups_ru.po b/locale/ubl-settings-usergroups_ru.po index f0144e8..b96e9e1 100644 --- a/locale/ubl-settings-usergroups_ru.po +++ b/locale/ubl-settings-usergroups_ru.po @@ -1152,3 +1152,8 @@ msgstr "Правила составления логина не соблюден #~ msgid "main group will be set to default group" #~ msgstr "получит(-ат) основную группу по умолчанию" + + +#: source/ubl-strings.h:302 +msgid "The password does not meet the password policy requirements" +msgstr "Пароль не соответствует требованиям политики паролей" \ No newline at end of file diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 1758e4b..b9894e3 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -13,6 +13,11 @@ include_directories(${VTE291_INCLUDE_DIRS}) link_directories(${VTE291_LIBRARY_DIRS}) add_definitions(${VTE291_CFLAGS_OTHER}) +pkg_check_modules(PWQ REQUIRED pwquality) +include_directories(${PWQ_INCLUDE_DIRS}) +link_directories(${PWQ_LIBRARY_DIRS}) +add_definitions(${PWQ_CFLAGS_OTHER}) + find_library(WEBKIT_LIBRARIES_FOUND webkit2gtk-4.0 webkit2gtk-web-extension-4.0) if(WEBKIT_LIBRARIES_FOUND) @@ -95,6 +100,7 @@ set(SOURCE_FILES set(LIBRARIES ${GTK_LIBRARIES} ${VTE291_LIBRARIES} + ${PWQ_LIBRARIES} ublsettings ublsettings-gtk3 ublsettingsui-gtk3 diff --git a/source/ubl-settings-usergroups-password.c b/source/ubl-settings-usergroups-password.c index f922fc0..fe70465 100644 --- a/source/ubl-settings-usergroups-password.c +++ b/source/ubl-settings-usergroups-password.c @@ -63,7 +63,7 @@ void on_password_accept(GtkWidget *self, dictionary *dict){ ubl_settings_usergroups_password_window *window = yon_dictionary_get_data(dict->first,ubl_settings_usergroups_password_window*); GtkEntry *entry = yon_dictionary_get_data(dict->first->next,GtkEntry*); char *password = (char*)gtk_entry_get_text(GTK_ENTRY(window->PasswordEntry)); - char *password_check = (char*)gtk_entry_get_text(GTK_ENTRY(window->RepeatPasswordEntry)); + char *password_check = (char*)gtk_entry_get_text(GTK_ENTRY(window->RepeatPasswordEntry)); if (yon_char_is_empty(password)){ char *pasted_hash = (char*)gtk_entry_get_text(GTK_ENTRY(window->PasswordHashEntry)); if (!yon_char_is_empty(pasted_hash)){ @@ -95,10 +95,39 @@ void on_password_accept(GtkWidget *self, dictionary *dict){ yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),PASSWORD_MISMATCH_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); return; } + pwquality_settings_t *settings = pwquality_default_settings(); + int password_strength = pwquality_check(settings,password,NULL,NULL,NULL); + if (password_strength<30){ + yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),WEAK_PASSWORD_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); + return; + } + } on_subwindow_close(self); } +void on_password_changed(GtkWidget *, ubl_settings_usergroups_password_window *window){ + pwquality_settings_t *settings = pwquality_default_settings(); + const char *new_password = gtk_entry_get_text(GTK_ENTRY(window->PasswordEntry)); + int password_strength = pwquality_check(settings,new_password,NULL,NULL,NULL); + gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(window->PasswordStrengthProgress),(gdouble)password_strength/100); + if (password_strength<30){ + gtk_style_context_add_class(gtk_widget_get_style_context(window->PasswordStrengthProgress),"redBox"); + gtk_style_context_remove_class(gtk_widget_get_style_context(window->PasswordStrengthProgress),"greenBox"); + gtk_style_context_remove_class(gtk_widget_get_style_context(window->PasswordStrengthProgress),"yellowBox"); + } else if (password_strength<60) { + gtk_style_context_add_class(gtk_widget_get_style_context(window->PasswordStrengthProgress),"yellowBox"); + gtk_style_context_remove_class(gtk_widget_get_style_context(window->PasswordStrengthProgress),"redBox"); + gtk_style_context_remove_class(gtk_widget_get_style_context(window->PasswordStrengthProgress),"greenBox"); + + } else { + gtk_style_context_add_class(gtk_widget_get_style_context(window->PasswordStrengthProgress),"greenBox"); + gtk_style_context_remove_class(gtk_widget_get_style_context(window->PasswordStrengthProgress),"redBox"); + gtk_style_context_remove_class(gtk_widget_get_style_context(window->PasswordStrengthProgress),"yellowBox"); + } + +} + void on_password_hash_sensitiveness(GtkWidget *,ubl_settings_usergroups_password_window *window){ if (!yon_char_is_empty(gtk_entry_get_text(GTK_ENTRY(window->PasswordEntry)))||!yon_char_is_empty(gtk_entry_get_text(GTK_ENTRY(window->RepeatPasswordEntry)))){ gtk_widget_set_sensitive(window->HashBox,0); @@ -123,6 +152,7 @@ ubl_settings_usergroups_password_window *yon_ubl_settings_usergroups_password_ne window->HashBox=yon_gtk_builder_get_widget(builder,"HashBox"); window->PasswordBox=yon_gtk_builder_get_widget(builder,"PasswordBox"); window->NoEncriptionCheck=yon_gtk_builder_get_widget(builder,"NoEncriptionCheck"); + window->PasswordStrengthProgress=yon_gtk_builder_get_widget(builder,"PasswordStrengthProgress"); window->UserCancelButton=yon_gtk_builder_get_widget(builder,"UserCancelButton"); window->UserOkButton=yon_gtk_builder_get_widget(builder,"UserOkButton"); @@ -130,6 +160,7 @@ ubl_settings_usergroups_password_window *yon_ubl_settings_usergroups_password_ne yon_window_config_custom_window_setup(GTK_WINDOW(window->CreateGroupWindow),"PasswordWindow"); g_signal_connect(G_OBJECT(window->UserCancelButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); g_signal_connect(G_OBJECT(window->PasswordEntry),"icon-press",G_CALLBACK(on_password_show_hide),NULL); + g_signal_connect(G_OBJECT(window->PasswordEntry),"changed",G_CALLBACK(on_password_changed),window); g_signal_connect(G_OBJECT(window->PasswordEntry),"changed",G_CALLBACK(on_password_hash_sensitiveness),window); g_signal_connect(G_OBJECT(window->RepeatPasswordEntry),"changed",G_CALLBACK(on_password_hash_sensitiveness),window); g_signal_connect(G_OBJECT(window->PasswordHashEntry),"changed",G_CALLBACK(on_password_hash_sensitiveness),window); diff --git a/source/ubl-settings-usergroups.h b/source/ubl-settings-usergroups.h index c7e0a4e..482c6a5 100644 --- a/source/ubl-settings-usergroups.h +++ b/source/ubl-settings-usergroups.h @@ -18,6 +18,7 @@ #include #endif #include "ubl-strings.h" +#include "pwquality.h" #define WIKI_LINK "https://wiki.ublinux.ru/software/programs_and_utilities/all/ubl-settings-usergroups" @@ -370,6 +371,7 @@ typedef struct{ GtkWidget *HashBox; GtkWidget *PasswordBox; GtkWidget *NoEncriptionCheck; + GtkWidget *PasswordStrengthProgress; } ubl_settings_usergroups_password_window; typedef struct { @@ -638,4 +640,5 @@ int yon_config_check_valid(); void on_home_changed(GtkWidget *self,ubl_settings_usergroups_user_window *window); gboolean yon_user_set_locales(GtkWidget *target); void *yon_load_languages(void *target); +void on_password_changed(GtkWidget *, ubl_settings_usergroups_password_window *window); #endif \ No newline at end of file diff --git a/source/ubl-strings.h b/source/ubl-strings.h index ee2fbfe..1e2cc6f 100644 --- a/source/ubl-strings.h +++ b/source/ubl-strings.h @@ -297,4 +297,5 @@ #define SYSTEM_LANGUAGE_LABEL _("System language:") #define REGIONAL_SETTINGS_LABEL _("Regional settings") #define SYSTEM_LABEL _("System") -#define INVALID_LOGIN_LABEL _("The login rules are not followed") \ No newline at end of file +#define INVALID_LOGIN_LABEL _("The login rules are not followed") +#define WEAK_PASSWORD_LABEL _("The password does not meet the password policy requirements") \ No newline at end of file diff --git a/ubl-settings-usergroups-password.glade b/ubl-settings-usergroups-password.glade index 50bce69..5ed4c65 100644 --- a/ubl-settings-usergroups-password.glade +++ b/ubl-settings-usergroups-password.glade @@ -139,6 +139,43 @@ 1 + + + True + False + 5 + + + True + False + + + + + + False + True + 0 + + + + + True + False + + + True + True + 1 + + + + + False + True + 2 + + Do not encrypt password @@ -150,7 +187,7 @@ False True - 2 + 3 @@ -161,7 +198,7 @@ False True - 3 + 4 @@ -281,8 +318,9 @@ - + + diff --git a/ubl-settings-usergroups.css b/ubl-settings-usergroups.css index 47d2ef3..c717974 100644 --- a/ubl-settings-usergroups.css +++ b/ubl-settings-usergroups.css @@ -118,7 +118,6 @@ background:transparent; border-color: #ea9999; border-style:solid; } - .chosenOutline{ transition: 0ms; border-width: 1px; @@ -126,6 +125,18 @@ background:transparent; border-style:solid; } +.greenBox > trough > progress{ + background-color: #99eaab; +} + +.redBox > trough > progress{ + background-color: #ea9999; +} + +.yellowBox > trough > progress{ + background-color: #f3f0ac; +} + .debugborders *{ border-width: 2px; border-color: #000000;