2014-12-01 40 views
0

我想使用彈簧安全認證用戶。我使用hiebrnate和jsf。 問題出在我看到的不同教程中,只有一個角色。但對我來說我有權限的不同的數據庫,並介紹了春季安全認證與休眠和jsf不同的配置文件和權限

表用戶

  • 用戶ID
  • 配置文件ID
  • 登錄
  • 密碼

表輪廓

  • PROFILE_ID
  • 輪廓

錶行動或許可

  • 的action_id
  • 行動
  • PROFILE_ID

我想知道是否有人知道如何實現這種或知道一些很好的教程。

回答

0

如果你想管理你的用戶角色,組和權限,你可以看到Spring Security documentation about schema。 這裏的一些片段和細節上面的鏈接:

create table users(
     username varchar_ignorecase(50) not null primary key, 
     password varchar_ignorecase(50) not null, 
     enabled boolean not null); 

    create table authorities (
     username varchar_ignorecase(50) not null, 
     authority varchar_ignorecase(50) not null, 
     constraint fk_authorities_users foreign key(username) references users(username)); 
     create unique index ix_auth_username on authorities (username,authority); 
create table groups (
    id bigint generated by default as identity(start with 0) primary key, 
    group_name varchar_ignorecase(50) not null); 

create table group_authorities (
    group_id bigint not null, 
    authority varchar(50) not null, 
    constraint fk_group_authorities_group foreign key(group_id) references groups(id)); 

create table group_members (
    id bigint generated by default as identity(start with 0) primary key, 
    username varchar(50) not null, 
    group_id bigint not null, 
    constraint fk_group_members_group foreign key(group_id) references groups(id)); 
+0

這樣,我必須使用模式的文檔中,但對我來說,我想就像我前面說的用我自己的表。有沒有辦法做到這一點 ? – Marina 2014-12-01 23:04:06

+0

你可以看到他們是怎麼做的並且定製他們的例子 – Pracede 2014-12-01 23:09:00

+0

但是在這個例子中,我們只有數據庫模式而不是在spring安全性上實現的例子 – Marina 2014-12-01 23:40:20