Added password strength meter

pull/309/head
parent d5f9ff7b59
commit d6108fa41d

@ -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 ""

@ -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 "Пароль не соответствует требованиям политики паролей"

@ -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

@ -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);

@ -18,6 +18,7 @@
#include <webkit2/webkit2.h>
#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

@ -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")
#define INVALID_LOGIN_LABEL _("The login rules are not followed")
#define WEAK_PASSWORD_LABEL _("The password does not meet the password policy requirements")

@ -139,6 +139,43 @@
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="spacing">5</property>
<child>
<object class="GtkBox" id="box1">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkProgressBar" id="PasswordStrengthProgress">
<property name="visible">True</property>
<property name="can-focus">False</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="NoEncriptionCheck">
<property name="label" translatable="yes">Do not encrypt password</property>
@ -150,7 +187,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
<property name="position">3</property>
</packing>
</child>
<child>
@ -161,7 +198,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
<property name="position">4</property>
</packing>
</child>
</object>
@ -281,8 +318,9 @@
</object>
<object class="GtkSizeGroup">
<widgets>
<widget name="label3"/>
<widget name="box1"/>
<widget name="label2"/>
<widget name="label3"/>
</widgets>
</object>
</interface>

@ -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;

Loading…
Cancel
Save