Skip to content

Commit 8822852

Browse files
committed
allow the default password even if it doesn't meet the normal password policy requirements
Signed-off-by: NAYANAR <[email protected]>
1 parent f66e4a3 commit 8822852

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

mcpgateway/bootstrap_db.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,10 @@ async def bootstrap_admin_user() -> None:
7676

7777
# Create admin user
7878
logger.info(f"Creating platform admin user: {settings.platform_admin_email}")
79-
admin_user = await auth_service.create_user(
79+
admin_user = await auth_service.create_platform_admin(
8080
email=settings.platform_admin_email,
8181
password=settings.platform_admin_password.get_secret_value(),
8282
full_name=settings.platform_admin_full_name,
83-
is_admin=True,
8483
)
8584

8685
# Mark admin user as email verified and require password change on first login
@@ -264,7 +263,6 @@ async def main() -> None:
264263

265264
if "gateways" not in insp.get_table_names():
266265
logger.info("Empty DB detected - creating baseline schema")
267-
268266
# Apply MariaDB compatibility fixes if needed
269267
if settings.database_url.startswith(("mariadb", "mysql")):
270268
# pylint: disable=import-outside-toplevel

mcpgateway/services/email_auth_service.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ async def get_user_by_email(self, email: str) -> Optional[EmailUser]:
273273
logger.error(f"Error getting user by email {email}: {e}")
274274
return None
275275

276-
async def create_user(self, email: str, password: str, full_name: Optional[str] = None, is_admin: bool = False, auth_provider: str = "local") -> EmailUser:
276+
async def create_user(self, email: str, password: str, full_name: Optional[str] = None, is_admin: bool = False, auth_provider: str = "local", skip_password_validation: bool = False) -> EmailUser:
277277
"""Create a new user with email authentication.
278278
279279
Args:
@@ -282,6 +282,7 @@ async def create_user(self, email: str, password: str, full_name: Optional[str]
282282
full_name: Optional full name for display
283283
is_admin: Whether user has admin privileges
284284
auth_provider: Authentication provider ('local', 'github', etc.)
285+
skip_password_validation: Skip password policy validation (for bootstrap)
285286
286287
Returns:
287288
EmailUser: The created user object
@@ -305,7 +306,8 @@ async def create_user(self, email: str, password: str, full_name: Optional[str]
305306

306307
# Validate inputs
307308
self.validate_email(email)
308-
self.validate_password(password)
309+
if not skip_password_validation:
310+
self.validate_password(password)
309311

310312
# Check if user already exists
311313
existing_user = await self.get_user_by_email(email)
@@ -462,6 +464,10 @@ async def change_password(self, email: str, old_password: Optional[str], new_pas
462464
# )
463465
# success # Returns: True
464466
"""
467+
# Validate old password is provided
468+
if old_password is None:
469+
raise AuthenticationError("Current password is required")
470+
465471
# First authenticate with old password
466472
user = await self.authenticate_user(email, old_password, ip_address, user_agent)
467473
if not user:
@@ -539,8 +545,8 @@ async def create_platform_admin(self, email: str, password: str, full_name: Opti
539545
logger.info(f"Updated platform admin user: {email}")
540546
return existing_admin
541547

542-
# Create new admin user
543-
admin_user = await self.create_user(email=email, password=password, full_name=full_name, is_admin=True, auth_provider="local")
548+
# Create new admin user - skip password validation during bootstrap
549+
admin_user = await self.create_user(email=email, password=password, full_name=full_name, is_admin=True, auth_provider="local", skip_password_validation=True)
544550

545551
logger.info(f"Created platform admin user: {email}")
546552
return admin_user

0 commit comments

Comments
 (0)