-
Notifications
You must be signed in to change notification settings - Fork 527
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(mfa/plugin): add dispatch mfa plugin (#5175)
* feat(mfa/plugin): add dispatch mfa plugin * feat(mfa/plugin): add dispatch mfa plugin * feat(mfa/plugin): add dispatch mfa plugin * feat: improve confirmation modal * Update src/dispatch/plugins/dispatch_core/plugin.py Co-authored-by: Marc Vilanova <39573146+mvilanova@users.noreply.github.com> --------- Co-authored-by: Marc Vilanova <39573146+mvilanova@users.noreply.github.com>
- Loading branch information
Showing
11 changed files
with
455 additions
and
44 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
45 changes: 45 additions & 0 deletions
45
src/dispatch/database/revisions/tenant/versions/2024-09-06_51eacaf1f62c.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 @@ | ||
"""Adds mfa_challenge to track challenges against core Dispatch MFA plugin. | ||
Revision ID: 51eacaf1f62c | ||
Revises: 71cd7ed999c4 | ||
Create Date: 2024-08-09 12:59:54.631968 | ||
""" | ||
from alembic import op | ||
import sqlalchemy as sa | ||
from sqlalchemy.dialects import postgresql | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "51eacaf1f62c" | ||
down_revision = "d6b3853be8e4" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.create_table( | ||
"mfa_challenge", | ||
sa.Column("id", sa.Integer(), nullable=False, autoincrement=True), | ||
sa.Column("valid", sa.Boolean(), nullable=True, server_default=sa.text("true")), | ||
sa.Column("reason", sa.String(), nullable=True), | ||
sa.Column("action", sa.String(), nullable=True), | ||
sa.Column("challenge_id", postgresql.UUID(as_uuid=True), nullable=True), | ||
sa.Column("dispatch_user_id", sa.Integer(), nullable=False), | ||
sa.Column("status", sa.String(), nullable=True), | ||
sa.Column("updated_at", sa.DateTime(), nullable=True), | ||
sa.Column("created_at", sa.DateTime(), nullable=True), | ||
sa.ForeignKeyConstraint( | ||
["dispatch_user_id"], | ||
["dispatch_core.dispatch_user.id"], | ||
), | ||
sa.PrimaryKeyConstraint("id"), | ||
sa.UniqueConstraint("challenge_id"), | ||
) | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_table("mfa_challenge") | ||
# ### end Alembic commands ### |
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,34 @@ | ||
class MfaException(Exception): | ||
"""Base exception for MFA-related errors.""" | ||
|
||
pass | ||
|
||
|
||
class InvalidChallengeError(MfaException): | ||
"""Raised when the challenge is invalid.""" | ||
|
||
pass | ||
|
||
|
||
class UserMismatchError(MfaException): | ||
"""Raised when the challenge doesn't belong to the current user.""" | ||
|
||
pass | ||
|
||
|
||
class ActionMismatchError(MfaException): | ||
"""Raised when the action doesn't match the challenge.""" | ||
|
||
pass | ||
|
||
|
||
class ExpiredChallengeError(MfaException): | ||
"""Raised when the challenge is no longer valid.""" | ||
|
||
pass | ||
|
||
|
||
class InvalidChallengeStateError(MfaException): | ||
"""Raised when the challenge is in an invalid state.""" | ||
|
||
pass |
Oops, something went wrong.