Commit Graph

99 Commits

Author SHA1 Message Date
Ubuntu 78bae3c2bb Improvments to logging\auditing 2026-05-19 10:38:26 +00:00
HawkveltGiteaAdmin f856aa5aea Merge pull request #37 from CoryHawkless/oidc-uplift
OIDC uplift
2026-05-19 14:48:58 +09:30
Ubuntu 815084132f refactor: standardize audit logging for ISO27001 compliance 2026-05-14 05:59:49 +00:00
Ubuntu 417d462fb9 Resolved issue with incorrect method for recording ip_address and user_agent 2026-05-08 09:25:27 +00:00
Ubuntu 81a221bd2b refactor: consolidate login audit logging and add superadmin user audit endpoints 2026-05-08 06:26:32 +00:00
Ubuntu 6d794106be fixed app double loading 2026-05-07 21:20:25 +00:00
Ubuntu c6f36ba62c feat: add user and event filtering to organization activity endpoint 2026-05-07 20:45:44 +00:00
Ubuntu d100fdff3b feat: allow admins to bypass approval flow when joining networks 2026-05-07 20:04:08 +00:00
coryHawkvelt 803bf4f4f2 refactor: consolidate user and superadmin sessions into unified model 2026-04-28 20:54:15 +09:30
coryHawkvelt 5abbadff9a Improve auditing 2026-04-28 17:17:54 +09:30
coryHawkvelt 63a3109a82 oidc-client mk1 2026-04-27 02:44:32 +09:30
HawkveltGiteaAdmin 32d517ea08 Merge pull request #30 from jamesii-b/v1.01/stable
Feat: Implemented Known hosts via CLI & Fix:  Permissons for ssh-cert
2026-04-26 22:55:07 +08:00
HawkveltGiteaAdmin 5b799b186f Merge branch 'main' into v1.01/stable 2026-04-26 22:54:54 +08:00
HawkveltGiteaAdmin 5d94299aaa Merge pull request #34 from CoryHawkless/cory-wip-session
fix(cors): handle wildcard origin with credentials and add unit tests
2026-04-26 22:34:50 +08:00
coryHawkvelt 02e95a4199 feat(organizations): email inviter when membership invite is accepted
When a user accepts an org invite, send a notification email to the
person who sent the invite with membership details (member name, email,
org name, role) and an optional View Organization button.

Added build_invite_accepted_html() template to email_templates.py,
wired it into the accept_invite() handler, and added a test case.
2026-04-26 18:36:58 +09:30
coryHawkvelt d48e6b2f97 feat: add sliding session timeout with idle and absolute caps 2026-04-26 18:12:37 +09:30
HawkveltGiteaAdmin dfe584b60a Merge pull request #35 from CoryHawkless/migration-fix
Migration fix
2026-04-26 14:42:36 +08:00
coryHawkvelt adfeb1bd0f fix: remove redundant unique constraints on id columns from all migrations
Remove UniqueConstraint('id') from all create_table calls in the initial
migration (40 occurrences) and the bulk constraint additions from the
superadmin migration (43 create + 43 drop). These were redundant with
PrimaryKeyConstraint('id') which already guarantees uniqueness.

Also removes duplicate unique enforcement on superadmins.email and
superadmin_sessions.token (kept the unique indexes, dropped the
table-level UniqueConstraints).

Fixes the root cause in BaseModel by removing unique=True from the id
column definition, which was causing Alembic autogenerate to produce
these redundant constraints.

Renames idx_cert_audit_org to ix_certificate_audit_logs_organization_id
to follow Alembic naming conventions.
2026-04-26 06:41:33 +00:00
coryHawkvelt 0fb98b4b38 Migration fix 2026-04-26 06:22:05 +00:00
coryHawkvelt 60799bbc52 fix(cors): handle wildcard origin with credentials and add unit tests
- Refactor CORS middleware to echo request origin when wildcard + credentials
  is configured (browsers reject Access-Control-Allow-Origin: * with
  Access-Control-Allow-Credentials: true)
- Add _is_origin_allowed() and _cors_origin_header() helpers
- Use CORS_SUPPORTS_CREDENTIALS config consistently
- Ensure consistent Access-Control-Allow-Headers in all CORS paths
- Fix redirect validation in get_token() to allow wildcard CORS origins
- Add 46 unit tests covering encryption round-trips, idempotency, key
  derivation, thread safety, CORS origin matching, and preflight responses
2026-04-26 01:12:39 +09:30
HawkveltGiteaAdmin 01c76ed172 Merge pull request #32 from CoryHawkless/cli-ui
Cli UI
2026-04-25 22:45:50 +08:00
coryHawkvelt 9738765258 fix: set 0600 permissions on SSH certificates and challenge files in gatehouse-cli 2026-04-26 00:13:37 +09:30
coryHawkvelt caf3fd2cd6 feat: add branded OAuth callback screen with auto-close to CLI client 2026-04-26 00:11:47 +09:30
coryHawkvelt bb977aedf9 test: add API-level coverage for internal helpers, schemas, and service validation 2026-04-25 22:17:41 +09:30
coryHawkvelt 1de10323af Fixed SSH test cases 2026-04-25 11:01:00 +09:30
nexgen_mirrors de6f39e7e3 feat(ssh): change SSH key uniqueness to per-user scope
Previously, SSH key fingerprints were globally unique across all users,
preventing the same key from being registered by different users. This
change makes fingerprint uniqueness scoped to individual users.

- Remove global unique constraints on payload and fingerprint columns
- Add composite unique constraint on (user_id, fingerprint)
- Make add_ssh_key operation idempotent for same user
- Return tuple (SSHKey, is_new) from service to indicate creation status
- Update API to return 200 for existing keys, 201 for new keys

BREAKING CHANGE: API behavior changed - duplicate key addition now
returns 200 OK instead of 409 Conflict. Service method signature changed
from returning SSHKey to tuple[SSHKey, bool].
2026-04-25 06:22:08 +09:30
nexgen_mirrors cec04f3cb2 feat(ssh): add multi-organization support for certificate signing
Add support for users who belong to multiple organizations to select
which organization's CA should sign their SSH certificates.

Changes:
- CLI: Add --org-id and --list-orgs options for organization selection
- API: Return MULTIPLE_ORGS_AMBIGUOUS error when org selection needed
- API: Add /users/me/organizations/simple endpoint for CLI org listing
- DB: Add organization_id to certificate_audit_logs for better tracking
- Include organization_name in certificate response for clarity
2026-04-24 22:27:24 +09:30
nexgen_mirrors 015c622016 test: add comprehensive integration test suite for IAM platform
Add 162 integration tests covering authentication flows, TOTP MFA,
SSH key/certificate management, organization workflows, multi-org
access, self-service features, admin operations, authorization,
security edge cases, department/principal management, CA management,
policy compliance, WebAuthn passkeys, and ZeroTier network access.

Includes:
- Reusable API client library with session management
- Test fixtures for users, organizations, memberships, and CAs
- Helper functions for SSH key generation and verification
- Documentation for running and writing tests

Also update test configuration to disable conflicting maas plugins
and configure WebAuthn/session settings for localhost testing.
2026-04-23 15:41:37 +09:30
nexgen_mirrors eb2fc6c8b3 Added soft deletes to all deletion functions and added deleted_at filters as required 2026-04-22 17:27:49 +09:30
nexgen_mirrors 33a7fdac59 Added worker tasks to docker-compose 2026-04-21 17:24:03 +09:30
nexgen_mirrors 1778dd85d5 Add superadmin routes to API 2026-04-21 17:11:03 +09:30
nexgen_mirrors aaec6af6ad feat(audit): add audit logging for organization invites
Log ORG_INVITE_SENT action when a user sends an organization invite,
capturing the invited email and role in the audit metadata.
2026-04-20 16:57:37 +09:30
nexgen_mirrors 7550940934 feat(api): return 403 when attempting to remove last owner
Handle edge case where removing a member would leave an organization
without any owners. Service layer raises ValueError for this scenario,
which the API endpoint catches and converts to a forbidden response
with actionable error message about transferring ownership.
2026-04-20 16:37:04 +09:30
nexgen_mirrors b2c2acc84f feat(org): add organization limit per user
Add 10 organization limit per user to prevent abuse. Includes
graceful fallback if count service is unavailable.

- Add get_user_org_count method to OrganizationService
- Check org count before allowing new organization creation
- Improve invite email mismatch error message for logged-in users
2026-04-20 15:04:44 +09:30
nexgen_mirrors 69f39dfa04 feat(auth): add authenticated resend verification endpoint
Add new /auth/me/resend-verification endpoint that allows logged-in users
to request a new email verification link. Includes rate limiting configuration
to prevent abuse of the verification email functionality.
2026-04-20 13:12:38 +09:30
nexgen_mirrors 29d54ca109 feat(api): add contact form endpoint for website enquiries
Add POST /api/v1/contact endpoint to handle contact form submissions
from the marketing website. Includes:
- ContactSchema for validation with HTML sanitization
- Honeypot field for spam protection
- Rate limiting (5 per hour)
- Email notification to info@secuird.tech via NotificationService
2026-04-17 15:55:19 +09:30
nexgen_mirrors 7480e9d62b fix(user): filter out soft-deleted memberships and organizations
Add get_active_memberships() method to User model that filters out
soft-deleted memberships and memberships of deleted organizations.
Update all usages of organization_memberships to use this method,
ensuring consistent handling of soft-deleted records across the
codebase. Also add deleted_at filters to CA queries in SSH helpers.
2026-04-10 00:39:44 +09:30
nexgen_mirrors f16bb88ad2 feat(scripts): add generic job runner for scheduled tasks
Add a configurable job runner script that executes Flask CLI commands
at specified intervals within Docker containers. Supports graceful
shutdown via SIGTERM/SIGINT signals and includes built-in job commands
for ZeroTier reconciliation and MFA compliance checks.
2026-04-10 00:37:38 +09:30
nexgen_mirrors ab967e8ec0 checkpoint: spiral-unknown-1775746582535 2026-04-10 00:26:22 +09:30
nexgen_mirrors 2a8b1b0d5b Bugfix - Enable admin to see users webauthn methods 2026-04-09 22:57:03 +09:30
JamesBhattarai 05cf3b3840 Feat: added --install-known-hosts & Fix: Permissons for ssh-cert
This allows users to copy the Host CA Pub key hosts directly into their ~/.ssh/known_hosts

Implemented chmod 600 for /tmp/ssh-cert (CERT_FILE_PATH)
2026-04-09 14:49:44 +05:45
nexgen_mirrors 04e3293b30 Docker maintenance 2026-04-07 20:03:11 +09:30
nexgen_mirrors d212ebe688 refactor(oidc): move OIDC module to versioned API path
- Move OIDC endpoints from gatehouse_app/api/oidc.py to gatehouse_app/api/v1/oidc.py
- Register OIDC discovery endpoint directly on app instead of separate blueprint
- Update service name from authy2-backend to secuird-backend in health check
2026-04-07 00:36:19 +09:30
nexgen_mirrors b567b7a518 refactor(oidc): move OIDC endpoints to versioned API path
Separate OIDC discovery endpoint into its own blueprint registered at
root level (required by OIDC spec for .well-known path). Move all other
OIDC endpoints to /api/v1/oidc to conform to API versioning standard.

BREAKING CHANGE: OIDC endpoint URLs changed from /oidc/* to /api/v1/oidc/*
2026-04-07 00:24:18 +09:30
nexgen_mirrors 1a4b4b220b bug fix 2026-04-06 23:56:03 +09:30
nexgen_mirrors 51b89fb885 refactor(auth): remove redirect_uri from OAuth flow initiation
Remove redirect_uri parameter from initiate_login_flow,
initiate_register_flow, and initiate_link_flow functions.
2026-04-06 23:50:20 +09:30
coryHawkvelt 6325d60097 feat(email): use HTML templates for all transactional emails
- Update org invite, password reset, email verification, and account activation emails to use HTML templates
- Update MFA deadline reminder and suspension notifications to use HTML templates
- Add html_body parameter to _send_email_async for rich email content
2026-04-05 15:44:22 +00:00
coryHawkvelt f2386ed1da fix(docker): align database config between docker-compose and .env
- Move POSTGRES_USER, POSTGRES_PASSWORD, POSTGRES_DB to .env
- Update docker-compose.yml to reference env vars instead of hardcoding
- Fix db healthcheck to use correct credentials from .env
- Update .env.example with matching placeholder values
- Update DATABASE_URL to use variable interpolation
2026-04-05 13:58:48 +00:00
HawkveltGiteaAdmin f1a6e40319 Merge pull request #19 from CoryHawkless/email-uplift
Email uplift
2026-04-05 14:18:06 +09:30
nexgen_mirrors 41bbdb4bef feat(email): add provider abstraction and HTML templates
Add pluggable email provider system supporting SMTP, Mailgun, and SendGrid
with factory pattern for runtime provider selection. Includes branded HTML
email templates for verification, password reset, MFA notifications, and
organization invites.

Also rebrands all email content from Gatehouse to Secuird, adds email
provider configuration options, and fixes duplicate log handlers in
development mode.
2026-04-04 16:55:00 +10:30