-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Introduce idp identifier and email columns
This commit primarily adds two columns to the user table, the idp identifier and the email. The idp identifier is used to map the idp user to the local user. Therefore, it is critical that the idp claim used for this is unique per user. The following breaking changes are introduced to the values.yaml file: The `jwt.usernameClaim' is now moved to `claimMapping.username' and specifies the identity token claim used for the username column. The `claimMapping.idpIdentifier' is added, which specifies the identity token claim used for the new idp identifier column and must be unique within the idp. The `claimMapping.email` is added, which specifies the identity token claim used for the new email column. The breaking changes are detailed in the PR description and in the release notes.
- Loading branch information
1 parent
8175f3f
commit b1dcc31
Showing
20 changed files
with
275 additions
and
120 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
45 changes: 45 additions & 0 deletions
45
backend/capellacollab/alembic/versions/028c72ddfd20_add_idp_identifier_and_email_column.py
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 @@ | ||
# SPDX-FileCopyrightText: Copyright DB InfraGO AG and contributors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
"""Add IdP identifier and email columns | ||
Revision ID: 028c72ddfd20 | ||
Revises: a1e59021e0d0 | ||
Create Date: 2024-07-22 14:49:47.575605 | ||
""" | ||
import sqlalchemy as sa | ||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "028c72ddfd20" | ||
down_revision = "a1e59021e0d0" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
op.add_column( | ||
"users", sa.Column("idp_identifier", sa.String(), nullable=True) | ||
) | ||
|
||
t_users = sa.Table("users", sa.MetaData(), autoload_with=op.get_bind()) | ||
|
||
users = op.get_bind().execute(sa.select(t_users)) | ||
for user in users: | ||
op.get_bind().execute( | ||
sa.update(t_users) | ||
.where(t_users.c.id == user.id) | ||
.values(idp_identifier=user.name) | ||
) | ||
|
||
op.alter_column("users", "idp_identifier", nullable=False) | ||
|
||
op.add_column("users", sa.Column("email", sa.String(), nullable=True)) | ||
op.create_index(op.f("ix_users_email"), "users", ["email"], unique=True) | ||
op.create_index( | ||
op.f("ix_users_idp_identifier"), | ||
"users", | ||
["idp_identifier"], | ||
unique=True, | ||
) |
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
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
Oops, something went wrong.