Skip to content

[Issue 55] user identity and access management system implementation - #96

Open
zephris wants to merge 28 commits into
mainfrom
issue-55-User_Identity_and_Access_Management_system_implementation
Open

[Issue 55] user identity and access management system implementation#96
zephris wants to merge 28 commits into
mainfrom
issue-55-User_Identity_and_Access_Management_system_implementation

Conversation

@zephris

@zephris zephris commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Change Summary

Adds Keycloak-based IAM integration, introduces self-service auth APIs for normal users, and improves deployment/configuration consistency across dev and prod.

  • Keycloak + Django admin OIDC integration is wired and configurable.
  • First-admin bootstrap/sync flows are automated via scripts.
  • New backend endpoints support user self-service signup/login.
  • Model and migration updates tighten chapter/user/membership behavior.
  • README and env examples were updated for setup and operational clarity.

Change Form

Fill this up (NA if not available). If a certain criteria is not met, can you please give a reason.

  • The pull request title has an issue number
  • The change works by "Smoke testing" or quick testing
  • The change has tests
  • The change has documentation

Other Information

Closes #55

Anthony Do and others added 14 commits July 11, 2026 07:19
…jango OIDC admin auth

- add Keycloak to dev/prod deployment flow with realm skeleton import support
- implement Django admin OIDC login integration using Keycloak
- add custom auth backend to map claims and effective realm roles to Django staff/superuser
- fetch effective roles through Keycloak Admin API to resolve admin authorization reliably
- add scripts to bootstrap env, deploy with Keycloak, provision linked admin user, and sync live admin password
- unify first-login credentials under FIRST_PLATFORM_ADMIN and sync related Keycloak/Django aliases
- ensure the same first admin identity is linked across Keycloak and Django admin paths
- update env examples and README documentation for setup, first-login credentials, and sync behavior

@oMakaron oMakaron left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm... nah gotta read ts

@zephris zephris added backend Task must have a back end issue enhancement New feature or request feature labels Jul 11, 2026
@zephris zephris self-assigned this Jul 11, 2026
@zephris
zephris requested a review from Copilot July 14, 2026 05:51

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Implements a Keycloak-backed IAM path for Django admin (OIDC) alongside new frontend-facing signup/login endpoints, and updates the data model + deployment tooling to support the new auth flows.

Changes:

  • Adds Keycloak OIDC integration wiring (settings, URLs, auth backend, env/config, docker-compose) for admin authentication.
  • Introduces self-service auth endpoints (/api/auth/signup/, /api/auth/login/) plus serializers and tests for “normal users”.
  • Renames core models (UsersUser, ChaptersChapter), adds membership constraints, and provides migrations/scripts/docs to keep dev/prod consistent.

Reviewed changes

Copilot reviewed 25 out of 26 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
server/pyproject.toml Adds mozilla-django-oidc dependency for OIDC integration.
server/poetry.lock Updates lockfile to include OIDC deps and bumps some packages.
server/api/urls.py Adds admin OIDC login route and conditionally mounts OIDC endpoints.
server/api/settings.py Adds AUTH_SOURCE-gated OIDC + Keycloak settings and backend selection.
server/agronomy_club/views.py Adds signup/login APIViews; tightens queryset typing patterns.
server/agronomy_club/urls.py Exposes /auth/signup/ and /auth/login/ under the API namespace.
server/agronomy_club/tests.py Updates model references; adds auth endpoint tests and membership validation tests.
server/agronomy_club/serializers.py Adds serializers for normal-user auth flows and user payload shaping.
server/agronomy_club/models.py Renames models, adds password hashing field/methods, and adds membership constraints + validation.
server/agronomy_club/migrations/0009_user_password_and_membership_constraints.py Adds password_hash, updates membership position default, and enforces unique membership constraint.
server/agronomy_club/migrations/0010_rename_chapters_chapter_rename_users_user_and_more.py Renames models and sets explicit DB table names.
server/agronomy_club/auth_views.py Adds an admin login redirector into the OIDC auth-init flow.
server/agronomy_club/auth_backends.py Adds a Keycloak-aware OIDC backend that maps realm roles to Django admin flags.
server/agronomy_club/admin.py Updates admin registrations to renamed models.
server/.env.example Adds Keycloak/OIDC configuration variables for local development.
scripts/sync-keycloak-first-admin-password.sh Automates first-admin password sync/rotation in Keycloak and .env.
scripts/ensure-keycloak-test-admin.sh Ensures a Keycloak test admin user exists and has platform_admin.
scripts/deploy-with-keycloak.sh One-command helper to bootstrap env, import realm skeleton, and run compose.
scripts/bootstrap-keycloak-env.sh Bootstraps Keycloak + Django env vars and unifies first-admin identity variables.
README.md Documents new auth endpoints and Keycloak deployment workflow.
keycloak/import/agronomy-club-realm-skeleton.json Adds an importable realm skeleton (including clients/roles/groups).
keycloak/agronomy-club-realm-skeleton.json Adds a realm skeleton source file (non-import path).
docker-compose.yml Adds a Keycloak service for dev deployments.
docker-compose.prod.yml Adds Keycloak service for prod deployments and wires server dependency.
client/.env.example Adds Keycloak env vars for frontend configuration.
.env.prod.example Adds Keycloak env vars for production configuration example.
Comments suppressed due to low confidence (1)

server/agronomy_club/admin.py:43

  • This introduces storage of user password hashes (password_hash) in the app-level User model; by default Django admin will display and allow editing this field on the User change form. Even though it's hashed, exposing it in the admin UI increases the risk of accidental disclosure/copying and makes it easy to corrupt accounts by editing it directly. Exclude the field from the ModelAdmin (or mark it read-only) and provide a dedicated password reset flow if needed.
@admin.register(User)
class UsersAdmin(admin.ModelAdmin):
    list_display = ('id', 'full_name', 'grad_yr', 'discipline', 'email', 'global_role')
    search_fields = ('id', 'full_name', 'discipline',)
    list_filter = ('grad_yr', 'global_role')

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread server/api/urls.py
Comment thread README.md
Comment thread server/agronomy_club/views.py
zephris and others added 3 commits July 14, 2026 13:57
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…nagement_system_implementation"

This reverts commit f0095fc, reversing
changes made to d8f0716.
@zephris
zephris marked this pull request as draft July 14, 2026 06:08

@Games4Doritos Games4Doritos left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some surface-level critiques I can give, unfortunately getting the rest of the MVP done first is our priority

Comment thread client/src/components/ui/ResourceListItem.tsx
Comment thread server/agronomy_club/serializers.py
Comment thread server/agronomy_club/urls.py
Comment thread server/agronomy_club/views.py
@zephris
zephris force-pushed the issue-55-User_Identity_and_Access_Management_system_implementation branch from e934f02 to d502a78 Compare July 15, 2026 07:03
@zephris
zephris force-pushed the issue-55-User_Identity_and_Access_Management_system_implementation branch from 6110c75 to f031de7 Compare July 15, 2026 08:17
@zephris
zephris marked this pull request as ready for review July 15, 2026 08:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend Task must have a back end issue enhancement New feature or request feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

User Identity and Access Management system implementation

6 participants