-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from keystone-scim/mysql-store
Add MySQL store
- Loading branch information
Showing
15 changed files
with
754 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import sqlalchemy as sa | ||
from sqlalchemy.dialects.mysql import JSON | ||
|
||
from keystone_scim.util.config import Config | ||
|
||
metadata = sa.MetaData() | ||
|
||
CONFIG = Config() | ||
_schema = CONFIG.get("store.mysql.schema", "public") | ||
|
||
|
||
users = sa.Table( | ||
"users", metadata, | ||
sa.Column("id", sa.VARCHAR, primary_key=True), | ||
sa.Column("externalId", sa.VARCHAR), | ||
sa.Column("locale", sa.VARCHAR), | ||
sa.Column("name", JSON, nullable=False), | ||
sa.Column("schemas", JSON, nullable=False), | ||
sa.Column("userName", sa.VARCHAR, nullable=False), | ||
sa.Column("displayName", sa.VARCHAR, nullable=False), | ||
sa.Column("active", sa.Boolean, default=True), | ||
sa.Column("customAttributes", JSON) | ||
) | ||
|
||
groups = sa.Table( | ||
"groups", metadata, | ||
sa.Column("id", sa.VARCHAR, primary_key=True), | ||
sa.Column("displayName", sa.VARCHAR, nullable=False), | ||
sa.Column("schemas", JSON, nullable=False) | ||
) | ||
|
||
users_groups = sa.Table( | ||
"users_groups", metadata, | ||
sa.Column("userId", sa.VARCHAR, sa.ForeignKey("users.id")), | ||
sa.Column("groupId", sa.VARCHAR, sa.ForeignKey("groups.id")) | ||
) | ||
|
||
user_emails = sa.Table( | ||
"user_emails", metadata, | ||
sa.Column("id", sa.VARCHAR, primary_key=True), | ||
sa.Column("userId", sa.VARCHAR, sa.ForeignKey("users.id")), | ||
sa.Column("primary", sa.Boolean, default=True), | ||
sa.Column("value", sa.VARCHAR), | ||
sa.Column("type", sa.VARCHAR) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# scim_schema = "CREATE SCHEMA IF NOT EXISTS `{}`;" | ||
|
||
users_tbl = """ | ||
CREATE TABLE IF NOT EXISTS `users` ( | ||
`id` VARCHAR(256) PRIMARY KEY, | ||
`externalId` VARCHAR(1024), | ||
`locale` VARCHAR(64), | ||
`name` JSON NOT NULL, | ||
`schemas` JSON NOT NULL, | ||
`userName` VARCHAR(512) UNIQUE NOT NULL, | ||
`displayName` VARCHAR(1024) NOT NULL, | ||
`customAttributes` JSON, | ||
`active` BOOLEAN, | ||
INDEX USING BTREE (`userName`) | ||
); | ||
""" | ||
|
||
groups_tbl = """ | ||
CREATE TABLE IF NOT EXISTS `groups` ( | ||
`id` VARCHAR(256) PRIMARY KEY, | ||
`displayName` VARCHAR(512) UNIQUE NOT NULL, | ||
`schemas` JSON NOT NULL, | ||
INDEX USING BTREE (`displayName`) | ||
); | ||
""" | ||
|
||
users_groups_tbl = """ | ||
CREATE TABLE IF NOT EXISTS `users_groups` ( | ||
`userId` VARCHAR(256) NOT NULL, | ||
`groupId` VARCHAR(256) NOT NULL, | ||
PRIMARY KEY(`userId`, `groupId`) | ||
); | ||
""" | ||
|
||
user_emails_tbl = """ | ||
CREATE TABLE IF NOT EXISTS `user_emails` ( | ||
`id` VARCHAR(256) PRIMARY KEY, | ||
`userId` VARCHAR(256) NOT NULL, | ||
`value` VARCHAR(512) NOT NULL, | ||
`primary` BOOLEAN DEFAULT TRUE, | ||
`type` VARCHAR(128) DEFAULT 'work', | ||
INDEX USING BTREE (`value`) | ||
); | ||
""" | ||
|
||
ddl_queries = [users_tbl, groups_tbl, users_groups_tbl, user_emails_tbl] |
Oops, something went wrong.