How To Store User Credentials In a Database

Опубликовано: 20 Июнь 2022
на канале: CS Student Strategies
1,700
13

Storing user credentials into a database is not difficult to do. Storing user credentials into a database securely is an entirely different matter. Tre shows how you can store user credentials into a MySQL database. This is not a demo on how to store credentials in production. It is a demo to show newer developers one possible way to store user credentials. If you are familiar with this topic please shower the comment section below with your expertise.

SQL SCRIPT
-- Create and Use Database
DROP DATABASE IF EXISTS auth;
CREATE DATABASE auth;
USE auth;

-- Create Table user
DROP TABLE IF EXISTS user;
CREATE TABLE user (id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(255) UNIQUE NOT NULL,
first_name VARCHAR(255),
last_name VARCHAR(255));

-- Create Table user_auth
DROP TABLE IF EXISTS user_auth;
CREATE TABLE user_auth (username VARCHAR(255) UNIQUE NOT NULL,
password VARCHAR(255) NOT NULL,
active TINYINT(1) DEFAULT 1,
FOREIGN KEY (username) REFERENCES user(username) ON DELETE CASCADE);

-- Create User auth_user
DROP USER IF EXISTS auth_user;
CREATE USER IF NOT EXISTS 'auth_user'@'localhost' IDENTIFIED BY 'p@$sw0rd';

-- Grant All Privileges On user_auth Database to New User
-- You should only grant necessary privileges to this user but I got lazy
GRANT ALL ON `auth`.* TO 'auth_user'@'localhost';

-- Flush Privileges
FLUSH PRIVILEGES;

Github
https://github.com/fclassvisions/cred...

Package Documentation
Express Docs
https://www.npmjs.com/package/express

MySQL 2 Docs
https://www.npmjs.com/package/mysql2

Argon 2 Docs
https://www.npmjs.com/package/argon2

DotEnv Docs
https://www.npmjs.com/package/dotenv

Cors Docs
https://www.npmjs.com/package/cors

Best Algorithm For User Creds Storage
https://infosecscout.com/best-algorit...


Смотрите видео How To Store User Credentials In a Database онлайн, длительностью часов минут секунд в хорошем качестве, которое загружено на канал CS Student Strategies 20 Июнь 2022. Делитесь ссылкой на видео в социальных сетях, чтобы ваши подписчики и друзья так же посмотрели это видео. Данный видеоклип посмотрели 1,700 раз и оно понравилось 13 посетителям.