Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

パスワードについて文字列を正規化するようにしてより判定を良くする #130

Merged
merged 2 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ tokio = { version = "1.29.1", features = ["full"] }
tower-http = { version = "0.4.4", features = ["cors"] }
tracing = "0.1.37"
tracing-subscriber = "0.3.17"
unicode-normalization = "0.1.22"
url = "2.4.0"
uuid = { version = "1.4.0", features = ["serde", "v4"] }
2 changes: 1 addition & 1 deletion src/app/authentication.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::sync::Arc;
use tracing::*;

pub async fn api_gen_passtoken(token_info: Basic, conn: Arc<Pool<Postgres>>) -> ReturnData<String> {
info!("Try gen passtoken");
info!("Try gen passtoken: {}", token_info.username());
let res = gen_passtoken(token_info, conn).await;
result_to_handler_with_log(
|_| Some("Success gen passtoken".to_string()),
Expand Down
7 changes: 4 additions & 3 deletions src/authentication.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use rand::{
};
use serde::{Deserialize, Serialize};
use std::env;
use unicode_normalization::UnicodeNormalization;
use uuid::Uuid;

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, sqlx::FromRow)]
Expand Down Expand Up @@ -107,7 +108,7 @@ pub fn gen_passtoken(role: Role, key: &str) -> Result<Passtoken> {
.map_err(|_| QrError::Environment("ADMINISTRATOR_LIMIT_DAYS".to_string()))?
.parse::<usize>()
.map_err(|_| QrError::Environment("ADMINISTRATOR_LIMIT_DAYS".to_string()))?;
if key == pass {
if key.nfc().collect::<String>() == pass.nfc().collect::<String>() {
Ok(Passtoken::new(role, limit_days))
} else {
Err(QrError::Authorized)
Expand All @@ -120,7 +121,7 @@ pub fn gen_passtoken(role: Role, key: &str) -> Result<Passtoken> {
.map_err(|_| QrError::Environment("EQUIPMENT_MANAGER_LIMIT_DAYS".to_string()))?
.parse::<usize>()
.map_err(|_| QrError::Environment("EQUIPMENT_MANAGER_LIMIT_DAYS".to_string()))?;
if key == pass {
if key.nfc().collect::<String>() == pass.nfc().collect::<String>() {
Ok(Passtoken::new(role, limit_days))
} else {
Err(QrError::Authorized)
Expand All @@ -133,7 +134,7 @@ pub fn gen_passtoken(role: Role, key: &str) -> Result<Passtoken> {
.map_err(|_| QrError::Environment("GENERAL_LIMIT_DAYS".to_string()))?
.parse::<usize>()
.map_err(|_| QrError::Environment("GENERAL_LIMIT_DAYS".to_string()))?;
if key == pass {
if key.nfc().collect::<String>() == pass.nfc().collect::<String>() {
Ok(Passtoken::new(role, limit_days))
} else {
Err(QrError::Authorized)
Expand Down
Loading