官术网_书友最值得收藏!

Step 3—MySQL database schema setup

Create a default database schema using the following scripts, and insert some users:

create table users(
username varchar(75) not null primary key,
password varchar(150) not null,
enabled boolean not null
);
create table authorities (
username varchar(75) not null,
authority varchar(50) not null,
constraint fk_authorities_users foreign key(username) references users(username)
);

Insert data into the preceding tables using the following scripts:

insert into users(username, password, enabled)
values('admin', '$2a$04$lcVPCpEk5DOCCAxOMleFcOJvIiYURH01P9rx1Y/pl.wJpkNTfWO6u', true);
insert into authorities(username, authority)
values('admin','ROLE_ADMIN');
insert into users(username, password, enabled)
values('user', '$2a$04$nbz5hF5uzq3qsjzY8ZLpnueDAvwj4x0U9SVtLPDROk4vpmuHdvG3a', true);
insert into authorities(username,authority)
values('user','ROLE_USER');

The password is one-way hashed using online tool http://www.devglan.com/online-tools/bcrypt-hash-generator. To compare the password we will use PasswordEncoder (Bcrypt).

Credentials are as follows:

  • User = admin and password = admin@password
  • User = user and password = user@password
It's important to note that, even though the role is named ROLE_ADMIN, the actual name is ADMIN, and this is what our code will be using while passing.
主站蜘蛛池模板: 沅江市| 宜宾县| 浠水县| 伊春市| 上蔡县| 屏边| 山西省| 扎赉特旗| 额济纳旗| 杭锦旗| 通州市| 开江县| 武定县| 柯坪县| 北辰区| 乌鲁木齐市| 花莲市| 云龙县| 济源市| 二连浩特市| 宣武区| 谢通门县| 曲靖市| 祁连县| 黄石市| 安徽省| 玉屏| 萍乡市| 栾城县| 若尔盖县| 石城县| 鹤庆县| 枣强县| 溆浦县| 正定县| 开化县| 兴文县| 湾仔区| 安宁市| 浑源县| 偏关县|