Skip to Content
Core

Core Module

The Core module provides foundational functionality for IOTA SDK platform. Every application built on the SDK requires this module.

Purpose

The Core module handles:

  • User authentication and authorization
  • Role-based access control (RBAC)
  • File uploads and management
  • Session management
  • Currency definitions
  • Tenant management (in multi-tenant mode)

Key Concepts

User

Central entity representing platform users. Users can:

  • Authenticate via username/password
  • Have multiple roles assigned
  • Belong to groups for organization
  • Upload avatars and files
  • Be blocked/deactivated

Role

Defines a set of permissions. The RBAC system allows:

  • Granular permission control
  • Role inheritance
  • Dynamic permission checks
  • Module-specific permissions

Session

Cookie-based session management:

  • Secure session storage (DB-backed)
  • Automatic expiration (configurable via SESSION_DURATION)
  • Expired sessions are rejected on authorize and removed from storage
  • Multi-device support
  • Session invalidation

Upload

File upload handling with:

  • Hash-based storage (deduplication)
  • Size and type validation
  • Multiple upload support
  • Secure file serving

Architecture

Components

Users

User management including:

  • Profile management
  • Password management (bcrypt hashed)
  • Avatar uploads
  • Account blocking
  • UI language preferences

Relationships:

Roles

Role management with:

  • Permission assignments
  • User role assignment
  • System and custom roles

Groups

User grouping for:

  • Organizational structure
  • Bulk operations
  • Reporting hierarchies

Settings

System configuration:

  • Application settings
  • Tenant-specific overrides
  • Localization defaults

Dashboard

Main dashboard view with:

  • Quick actions
  • Recent activity
  • Navigation shortcuts

Account

User self-service:

  • Profile editing
  • Password changes
  • Language selection

API Reference

GraphQL Schema

The Core module exposes GraphQL endpoints:

TypeQueriesMutations
Useruser, users(use REST /users for create/update/delete)
Uploadupload, uploadsuploadFile, uploadFileWithSlug
Authauthenticate(email!, password!) → Session! (logout via REST GET /logout)
SessiondeleteSession(token: String!) (resolver may be unimplemented)

See API Reference for detailed schema documentation.

REST Endpoints

Standard REST endpoints for form submissions:

EndpointMethodPurpose
/healthGETLiveness probe (JSON {"status":"healthy"}); checks DB and Spotlight readiness. No auth.
/usersGETList users
/usersPOSTCreate user
/users/:idGETView user
/users/:idPOSTUpdate user
/users/:idDELETEDelete user
/loginPOSTAuthenticate
/logoutGETEnd session

When the application registers them, the Core module also provides optional detailed health and system info UI (authenticated):

EndpointMethodPurpose
/system/healthGETDetailed health (JSON, capabilities). Requires auth.
/system/infoGETSystem information and metrics UI (HTML). Requires auth.
/system/info/metricsGETMetrics partial (HTMX). Requires auth.

Additional Core REST routes (when registered): /spotlight/search (GET, search); /uploads (POST, form uploads); /api/uploads (POST, when upload API enabled via ModuleOptions); /roles, /groups (CRUD); /account, /account/sessions (profile and session management); /settings/sessions (admin session list/revoke); /login/2fa/setup, /login/2fa/verify, /login/2fa/verify/recovery, /login/2fa/verify/resend (2FA when enabled).

Permissions

Available Permissions

PermissionDescription
User.ReadView user list and details
User.CreateCreate new users
User.UpdateModify existing users
User.DeleteRemove users
User.UpdateBlockStatusBlock or unblock user
Role.ReadView roles
Role.CreateCreate roles
Role.UpdateModify roles
Role.DeleteDelete roles
Group.ReadView groups
Group.CreateCreate groups
Group.UpdateModify groups
Group.DeleteDelete groups
Upload.ReadView uploads
Upload.CreateUpload files
Upload.UpdateUpdate upload metadata
Upload.DeleteDelete uploads
Session.ReadView sessions (admin)
Session.DeleteRevoke sessions

Default Roles

RolePermissions
SuperadminAll permissions
AdminUsers, roles, settings management
ManagerView users, limited edit
UserView own profile only

When an authenticated user lacks the required permission for a resource, the framework returns 403 Forbidden and can render a dedicated forbidden page instead of redirecting to login.

Integration with Other Modules

Service Access

Other modules access Core services via the registry:

Shared Entities

Core entities used across modules:

EntityUsage
UserCreated by, assigned to, approved by
UploadAttachments, avatars, documents
CurrencyFinancial transactions
RolePermission checks

Events

The Core module publishes domain events:

EventDescription
UserCreatedNew user registered
UserUpdatedUser profile changed
UserPasswordChangedPassword updated
UserBlockedUser deactivated
RoleAssignedRole given to user
UploadCreatedFile uploaded

Configuration

Module Options

Configure during registration via core.ModuleOptions (passed to core.NewModule(opts)):

  • Permission Schema - Define available permissions (e.g. for Roles UI).
  • LoginControllerOptions - Customize middleware or access checks for login routes (e.g. custom “login gate”).
  • DashboardLinkPermissions - Permissions required to see the Dashboard link in the sidebar; if empty, default visibility applies.
  • SettingsLinkPermissions - Permissions required to see the Settings link in the sidebar.
  • UploadsAuthorizer / DefaultTenantID - For upload API when using API-based uploads.

The sidebar shows navigation items only to users who have at least one role; users with no roles see no sidebar nav items. The Settings link defaults to /settings/logo.

Environment Variables

VariablePurpose
SESSION_DURATIONSession duration
SID_COOKIE_KEYSession cookie name
MAX_UPLOAD_SIZEFile upload size limit
MAX_UPLOAD_MEMORYMultipart form memory limit (bytes)
UPLOADS_PATHFile storage directory

Usage

The Core module is included in BuiltInModules and registered via modules.Load(app, modules.BuiltInModules...). To add a custom module, pass it to modules.Load(app, yourModule) (or modules.Load(app, modules.BuiltInModules..., yourModule)); each module’s Register(app) is called by Load. There is no app.RegisterModule(module)—use modules.Load instead.

Best Practices

  1. Always check permissions - Use middleware for route protection
  2. Validate uploads - Check file types and sizes
  3. Hash passwords - Never store plain text passwords
  4. Use events - Subscribe to user events for integrations
  5. Session security - Rotate session IDs on privilege change

Next Steps

Last updated on