一个数据库的多个站点和身份验证

Multiple Sites and Authentications with one Database

这可能是一个简单的问题,但这是我第一次以这种方式建立网站,我需要一些建议。

设置:

问题:

问题:

这取决于您的授权框架。

身份验证 标识谁在访问您的站点,该身份的一部分是用户、company/domain 和他们所属的 role/group。

授权 是对允许用户 company/domain 或 role/group 访问的内容的描述。

您可能知道 cookie 和 username/passwords 用于用户识别。用户存储在数据库中并映射到他们所属的company/domain。并且用户也映射到他们所属的role/group。

select userID, company from users where username = ?, $username

select group from groups where userID = ?, $userID

数据库中的某些记录的范围可能是单个 domain/company,而其他记录的范围可能是 role/group。您将 domain/company 或 role/group 作为列添加到数据库中,并在查询中使用它。

select content from companyPages where company = ?

select content from groupPages where group in (select group from groups where userID = ?))

您也可以让来自多个 companies/domains 的用户使用相同的组。

并将其放在一起:

Select content from pages WHERE group in (select group from groups where userID= ?) AND company = (select company from users where userID=?);

基本上您必须定义您的授权方案并将其映射到您的数据模型。