diff --git a/BeWo/View/PasswortAenderungsView.xaml.cs b/BeWo/View/PasswortAenderungsView.xaml.cs index ded3194f2..40e155da7 100644 --- a/BeWo/View/PasswortAenderungsView.xaml.cs +++ b/BeWo/View/PasswortAenderungsView.xaml.cs @@ -1,11 +1,7 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text.RegularExpressions; using System.Windows; using System.Windows.Input; using System.Windows.Media; -using BeWo.Core; using BeWo.PasswortSecurity; using BeWo.ServiceProxy; using BeWo.ViewModel; diff --git a/BeWoAllReports.sln b/BeWoAllReports.sln index 790c641bb..92dcdc6b1 100644 --- a/BeWoAllReports.sln +++ b/BeWoAllReports.sln @@ -784,6 +784,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FlexibleJugendarbeitFrankfu EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SHKServiceSBD", "ReportImp\SHKServiceSBD\SHKServiceSBD.csproj", "{4C29CCFD-4B7A-44CC-B6DD-39AEBA2E4DFE}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SkmViersen", "ReportImp\SkmViersen\SkmViersen.csproj", "{E8A02131-7E1A-47DA-A8BE-44FD86311F5F}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FenixSozialeDienste", "ReportImp\FenixSozialeDienste\FenixSozialeDienste.csproj", "{8404C9FB-662A-4676-8454-64ED3CED2014}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|.NET = Debug|.NET @@ -9575,6 +9579,54 @@ Global {4C29CCFD-4B7A-44CC-B6DD-39AEBA2E4DFE}.Release|Mixed Platforms.Build.0 = Release|Any CPU {4C29CCFD-4B7A-44CC-B6DD-39AEBA2E4DFE}.Release|x86.ActiveCfg = Release|Any CPU {4C29CCFD-4B7A-44CC-B6DD-39AEBA2E4DFE}.Release|x86.Build.0 = Release|Any CPU + {E8A02131-7E1A-47DA-A8BE-44FD86311F5F}.Debug|.NET.ActiveCfg = Debug|Any CPU + {E8A02131-7E1A-47DA-A8BE-44FD86311F5F}.Debug|.NET.Build.0 = Debug|Any CPU + {E8A02131-7E1A-47DA-A8BE-44FD86311F5F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E8A02131-7E1A-47DA-A8BE-44FD86311F5F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E8A02131-7E1A-47DA-A8BE-44FD86311F5F}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {E8A02131-7E1A-47DA-A8BE-44FD86311F5F}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {E8A02131-7E1A-47DA-A8BE-44FD86311F5F}.Debug|x86.ActiveCfg = Debug|Any CPU + {E8A02131-7E1A-47DA-A8BE-44FD86311F5F}.Debug|x86.Build.0 = Debug|Any CPU + {E8A02131-7E1A-47DA-A8BE-44FD86311F5F}.DebugRemote|.NET.ActiveCfg = Debug|Any CPU + {E8A02131-7E1A-47DA-A8BE-44FD86311F5F}.DebugRemote|.NET.Build.0 = Debug|Any CPU + {E8A02131-7E1A-47DA-A8BE-44FD86311F5F}.DebugRemote|Any CPU.ActiveCfg = Debug|Any CPU + {E8A02131-7E1A-47DA-A8BE-44FD86311F5F}.DebugRemote|Any CPU.Build.0 = Debug|Any CPU + {E8A02131-7E1A-47DA-A8BE-44FD86311F5F}.DebugRemote|Mixed Platforms.ActiveCfg = Debug|Any CPU + {E8A02131-7E1A-47DA-A8BE-44FD86311F5F}.DebugRemote|Mixed Platforms.Build.0 = Debug|Any CPU + {E8A02131-7E1A-47DA-A8BE-44FD86311F5F}.DebugRemote|x86.ActiveCfg = Debug|Any CPU + {E8A02131-7E1A-47DA-A8BE-44FD86311F5F}.DebugRemote|x86.Build.0 = Debug|Any CPU + {E8A02131-7E1A-47DA-A8BE-44FD86311F5F}.Release|.NET.ActiveCfg = Release|Any CPU + {E8A02131-7E1A-47DA-A8BE-44FD86311F5F}.Release|.NET.Build.0 = Release|Any CPU + {E8A02131-7E1A-47DA-A8BE-44FD86311F5F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E8A02131-7E1A-47DA-A8BE-44FD86311F5F}.Release|Any CPU.Build.0 = Release|Any CPU + {E8A02131-7E1A-47DA-A8BE-44FD86311F5F}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {E8A02131-7E1A-47DA-A8BE-44FD86311F5F}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {E8A02131-7E1A-47DA-A8BE-44FD86311F5F}.Release|x86.ActiveCfg = Release|Any CPU + {E8A02131-7E1A-47DA-A8BE-44FD86311F5F}.Release|x86.Build.0 = Release|Any CPU + {8404C9FB-662A-4676-8454-64ED3CED2014}.Debug|.NET.ActiveCfg = Debug|Any CPU + {8404C9FB-662A-4676-8454-64ED3CED2014}.Debug|.NET.Build.0 = Debug|Any CPU + {8404C9FB-662A-4676-8454-64ED3CED2014}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8404C9FB-662A-4676-8454-64ED3CED2014}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8404C9FB-662A-4676-8454-64ED3CED2014}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {8404C9FB-662A-4676-8454-64ED3CED2014}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {8404C9FB-662A-4676-8454-64ED3CED2014}.Debug|x86.ActiveCfg = Debug|Any CPU + {8404C9FB-662A-4676-8454-64ED3CED2014}.Debug|x86.Build.0 = Debug|Any CPU + {8404C9FB-662A-4676-8454-64ED3CED2014}.DebugRemote|.NET.ActiveCfg = Debug|Any CPU + {8404C9FB-662A-4676-8454-64ED3CED2014}.DebugRemote|.NET.Build.0 = Debug|Any CPU + {8404C9FB-662A-4676-8454-64ED3CED2014}.DebugRemote|Any CPU.ActiveCfg = Debug|Any CPU + {8404C9FB-662A-4676-8454-64ED3CED2014}.DebugRemote|Any CPU.Build.0 = Debug|Any CPU + {8404C9FB-662A-4676-8454-64ED3CED2014}.DebugRemote|Mixed Platforms.ActiveCfg = Debug|Any CPU + {8404C9FB-662A-4676-8454-64ED3CED2014}.DebugRemote|Mixed Platforms.Build.0 = Debug|Any CPU + {8404C9FB-662A-4676-8454-64ED3CED2014}.DebugRemote|x86.ActiveCfg = Debug|Any CPU + {8404C9FB-662A-4676-8454-64ED3CED2014}.DebugRemote|x86.Build.0 = Debug|Any CPU + {8404C9FB-662A-4676-8454-64ED3CED2014}.Release|.NET.ActiveCfg = Release|Any CPU + {8404C9FB-662A-4676-8454-64ED3CED2014}.Release|.NET.Build.0 = Release|Any CPU + {8404C9FB-662A-4676-8454-64ED3CED2014}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8404C9FB-662A-4676-8454-64ED3CED2014}.Release|Any CPU.Build.0 = Release|Any CPU + {8404C9FB-662A-4676-8454-64ED3CED2014}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {8404C9FB-662A-4676-8454-64ED3CED2014}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {8404C9FB-662A-4676-8454-64ED3CED2014}.Release|x86.ActiveCfg = Release|Any CPU + {8404C9FB-662A-4676-8454-64ED3CED2014}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -9965,6 +10017,8 @@ Global {8725A58B-AB80-4906-9B13-2D4144FF09EA} = {D8A691C5-146D-4613-86CC-438F02FE9106} {E02EB6C5-1DD6-4EF4-BD60-F91783498DA7} = {D8A691C5-146D-4613-86CC-438F02FE9106} {4C29CCFD-4B7A-44CC-B6DD-39AEBA2E4DFE} = {D8A691C5-146D-4613-86CC-438F02FE9106} + {E8A02131-7E1A-47DA-A8BE-44FD86311F5F} = {D8A691C5-146D-4613-86CC-438F02FE9106} + {8404C9FB-662A-4676-8454-64ED3CED2014} = {D8A691C5-146D-4613-86CC-438F02FE9106} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {FBE985BB-9F0F-4DBB-8F94-ABC37A803FF9} diff --git a/BeWoPlanerMobil/BeWoPlanerMobil.csproj b/BeWoPlanerMobil/BeWoPlanerMobil.csproj index d2323abb6..f200008f4 100644 --- a/BeWoPlanerMobil/BeWoPlanerMobil.csproj +++ b/BeWoPlanerMobil/BeWoPlanerMobil.csproj @@ -4659,6 +4659,7 @@ + @@ -5092,7 +5093,7 @@ - False + True False 8808 / diff --git a/BeWoPlanerMobil/Controllers/MainController.cs b/BeWoPlanerMobil/Controllers/MainController.cs index e60116c7b..2cecdb7e4 100644 --- a/BeWoPlanerMobil/Controllers/MainController.cs +++ b/BeWoPlanerMobil/Controllers/MainController.cs @@ -3805,6 +3805,8 @@ namespace BeWoPlanerMobil.Controllers // ToDo: Testen! falsches oldPassword, kein oldPassword, newPassword stimmt nicht mit confirmationPassword überein, kein confirmationPassword, kein newPassword UserService.ChangePassword(userName, userVersion, oldPassword, newPassword); + // ToDo: Regeln beachten, welche Passwortstärke mindestens erreicht werden muss. + return RedirectToActionPermanent("Main"); } } diff --git a/BeWoPlanerMobil/Scripts/utils/password-security.js b/BeWoPlanerMobil/Scripts/utils/password-security.js new file mode 100644 index 000000000..afbb9e13c --- /dev/null +++ b/BeWoPlanerMobil/Scripts/utils/password-security.js @@ -0,0 +1,327 @@ +class PasswordSecurity { + #numbers = "0123456789"; + #lowercaseLetters = "abcdefghijklmnopqrstuvwxyz"; + #uppercaseLetters = "ABDEFGHIJKLMNOPQRSTUVWXYZ"; + #lowercaseUmlauts = "äöüß"; + #uppercaseUmlauts = "ÄÖÜ"; + #specialChars1 = "\\\"\'µ@€!"; + #specialChars2 = "&/()=?+#*"; + #specialChars3 = ",.-;:_><|"; + #specialChars4 = "§$%'{[]}´"; + #specialChars5 = "`^°~²³"; + + #isPartial = false; + #partialPassword = ""; + #passwordLengthDifference = 0; + #score = 0; + #previousValue = 0; + #schalter = false; + #previousValues = []; + + #passwordLabelId = ""; + + constructor(pwLabelId) { + this.#passwordLabelId = pwLabelId; + } + + validatePassword(password) { + if (false === isUndefinedOrNull(password) && password.length > 0) { + var sx = ""; + var passwordStrength = -1; + + for (var i = 0; i < password.length; i++) { + sx += password[i]; + + if (sx.length < this.#partialPassword.length) { + this.#isPartial = true; + this.#passwordLengthDifference = this.#partialPassword.length - sx.length; + } + + if (this.#partialPassword !== sx) { + this.#partialPassword = sx; + } + + passwordStrength = this.#calculatePasswordStrength(sx); + } + + this.#displayPasswordStrength(passwordStrength); + return; + } + + this.#score = 0; + this.#previousValue = 0; + + this.#displayPasswordStrength(-1); + } + + #getIntegerFromArray(arr, index) { + if (arr === undefined || arr === null || arr.length < index) { + return 0; + } + + var intValue = $.parseInt(arr[index], 10); + + return $.isNumeric(intValue) ? intValue : 0; + } + + #getLastValue() { + if (this.#previousValues === undefined || this.#previousValues === null || this.#previousValues.length === 0) { + return 0; + } + + return this.#previousValues[this.#previousValues.length - 1]; + } + + #calculatePasswordStrength(passwordToValidate) { + var passwordStrength = 0; + this.#previousValue = 0; + + if (this.#isPartial === true) { + if (this.#passwordLengthDifference === 1) { + this.#score -= this.#getLastValue(); + this.#previousValues.pop(); + } else { + for (var i = 0; i < this.#passwordLengthDifference; i++) { + this.#score -= this.#getLastValue(); + this.#previousValues.pop(); + } + } + + this.#isPartial = false; + } else { + var passwordLength = passwordToValidate.length; + + if (passwordLength >= 6 && passwordLength < 9) { + this.#score += 1; + this.#previousValue = 1; + this.#schalter = true; + } + + if (passwordLength >= 9 && passwordLength < 12) { + this.#score += 2; + this.#previousValue = 2; + this.#schalter = true; + } + + if (passwordLength >= 12 && passwordLength < 18) { + this.#score += 3; + this.#previousValue = 3; + this.#schalter = true; + } + + if (passwordLength >= 18) { + this.#score += 4; + this.#previousValue = 4; + this.#schalter = true; + } + + var passwordAsArray = Array.from(passwordToValidate); + + // Zahlen + var containsNumbers = false; + for (var i = 0; i < passwordAsArray.length; i++) { + if (this.#numbers.includes(passwordAsArray[i])) { + containsNumbers = true; + break; + } + } + + // Kleinbuchstaben + var containsLowercaseLetters = false; + for (var i = 0; i < passwordAsArray.length; i++) { + if (this.#lowercaseLetters.includes(passwordAsArray[i])) { + containsLowercaseLetters = true; + break; + } + } + + // Großbuchstaben + var containsUppercaseLetters = false; + for (var i = 0; i < passwordAsArray.length; i++) { + if (this.#uppercaseLetters.includes(passwordAsArray[i])) { + containsUppercaseLetters = true; + break; + } + } + + // Kleinumlaute + var containsLowercaseUmlauts = false; + for (var i = 0; i < passwordAsArray.length; i++) { + if (this.#lowercaseUmlauts.includes(passwordAsArray[i])) { + containsLowercaseUmlauts = true; + break; + } + } + + // Großumlaute + var containsUppercaseUmlauts = false; + for (var i = 0; i < passwordAsArray.length; i++) { + if (this.#uppercaseUmlauts.includes(passwordAsArray[i])) { + containsUppercaseUmlauts = true; + break; + } + } + + // Sonderzeichen 1 + var containsSpecialCharacters1 = false; + for (var i = 0; i < passwordAsArray.length; i++) { + if (this.#specialChars1.includes(passwordAsArray[i])) { + containsSpecialCharacters1 = true; + break; + } + } + + var containsSpecialCharacters2 = false; + for (var i = 0; i < passwordAsArray.length; i++) { + if (this.#specialChars2.includes(passwordAsArray[i])) { + containsSpecialCharacters2 = true; + break; + } + } + + var containsSpecialCharacters3 = false; + for (var i = 0; i < passwordAsArray.length; i++) { + if (this.#specialChars3.includes(passwordAsArray[i])) { + containsSpecialCharacters3 = true; + break; + } + } + + var containsSpecialCharacters4 = false; + for (var i = 0; i < passwordAsArray.length; i++) { + if (this.#specialChars4.includes(passwordAsArray[i])) { + containsSpecialCharacters4 = true; + break; + } + } + + var containsSpecialCharacters5 = false; + for (var i = 0; i < passwordAsArray.length; i++) { + if (this.#specialChars5.includes(passwordAsArray[i])) { + containsSpecialCharacters5 = true; + break; + } + } + + if (containsNumbers === true) { + this.#addScoreValue(3); + } + + if (containsLowercaseLetters === true) { + this.#addScoreValue(2); + } + + if (containsUppercaseLetters === true) { + this.#addScoreValue(3); + } + + if (containsLowercaseUmlauts === true) { + this.#addScoreValue(2); + } + + if (containsUppercaseUmlauts === true) { + this.#addScoreValue(2); + } + + if (containsSpecialCharacters1 === true) { + this.#addScoreValue(4); + } + + if (containsSpecialCharacters2 === true) { + this.#addScoreValue(4); + } + + if (containsSpecialCharacters3 === true) { + this.#addScoreValue(4); + } + + if (containsSpecialCharacters4 === true) { + this.#addScoreValue(4); + } + + if (containsSpecialCharacters5 === true) { + this.#addScoreValue(4); + } + + this.#previousValues.push(this.#previousValue); + } + + if (this.#score <= 15) { + passwordStrength = 0; + } + + if (this.#score > 15 && this.#score <= 55) { + passwordStrength = 1; + } + + if (this.#score > 55 && this.#score <= 115) { + passwordStrength = 2; + } + + if (this.#score > 115 && this.#score <= 155) { + passwordStrength = 3; + } + + if (this.#score > 155) { + passwordStrength = 4; + } + + return passwordStrength; + } + + #addScoreValue(defaultValue) { + if (defaultValue === undefined || defaultValue === null || false === $.isNumeric(defaultValue)) { + return; + } + + this.#score += defaultValue; + + if (this.#schalter === true) { + this.#previousValue += defaultValue; + } else { + this.#previousValue = defaultValue; + } + } + + #displayPasswordStrength(passwordStrength) { + var passwordLabel = $("#" + this.#passwordLabelId); + + if (passwordStrength === undefined || !$.isNumeric(passwordStrength) || !passwordLabel.length) { + return; + } + + passwordLabel.removeClass("text-success text-danger text-warning"); + + switch (passwordStrength) { + case -1: + passwordLabel.addClass("d-none"); + passwordLabel.html(""); + break; + case 0: + passwordLabel.removeClass("d-none"); + passwordLabel.html("Passwortstärke: Sehr schwach"); + passwordLabel.addClass("text-danger"); + break; + case 1: + passwordLabel.removeClass("d-none"); + passwordLabel.html("Passwortstärke: Schwach"); + passwordLabel.addClass("text-danger"); + break; + case 2: + passwordLabel.removeClass("d-none"); + passwordLabel.html("Passwortstärke: Mittel"); + passwordLabel.addClass("text-warning"); + break; + case 3: + passwordLabel.removeClass("d-none"); + passwordLabel.html("Passwortstärke: Stark"); + passwordLabel.addClass("text-success"); + break; + case 4: + passwordLabel.removeClass("d-none"); + passwordLabel.html("Passwortstärke: Sehr stark"); + passwordLabel.addClass("text-success"); + break; + } + } +} \ No newline at end of file diff --git a/BeWoPlanerMobil/Views/Main/Main.cshtml b/BeWoPlanerMobil/Views/Main/Main.cshtml index 10ca812ac..06c2d7e20 100644 --- a/BeWoPlanerMobil/Views/Main/Main.cshtml +++ b/BeWoPlanerMobil/Views/Main/Main.cshtml @@ -16,118 +16,11 @@ } +