App Logo
Plugins

Organizations Plugin

Manage multi-tenant organizations, members and teams. Enables team collaboration, and email-based invitations.

Overview

The Organizations plugin provides multi-tenancy and team management capabilities. It enables users to create organizations, manage members with roles, organize members into teams, and send email-based invitations.

Core Entities

  • Organizations: Owner-based organizational units
  • Invitations: Email-based invitations for joining organizations
  • Members: Users assigned to organizations with roles
  • Teams: Group members into teams within organizations
  • Team Members: Users assigned to teams within organizations

Features

  • Multi-tenant organization management
  • Role-based member management within organizations
  • Team organization and management within organizations
  • Email-based member invitations with configurable expiration
  • Team member management
  • Full lifecycle management (create, read, update, delete operations)

NOTE

This plugin has a dependency on the Access Control plugin for role-based access control. Make sure to configure the Access Control plugin to utilize all features of the Organizations plugin.


Configuration

Standalone Mode:

[organizations]
enabled = true
organizations_limit = 10 # Optional limit on number of organizations (set to 0 for unlimited)
members_limit = 100 # Optional limit on number of members per organization (set to 0 for unlimited)
invitations_limit = 100 # Optional limit on number of invitations sent to a user (100 by default)
invitation_expires_in = "24h" # Expiration time for organization invitations (24h = 1 day by default)
require_email_verified_on_invitation = true # Whether to require the invited user's email to be verified before accepting or rejecting an organization invitation (false by default)

Library Mode:

import (
  "time"

  organizationsplugin "github.com/authula/authula/plugins/organizations"
  organizationsplugintypes "github.com/authula/authula/plugins/organizations/types"
)

organizationsplugin.New(&organizationsplugintypes.OrganizationsPluginConfig{
  Enabled:             true,
  OrganizationsLimit:  10,
  MembersLimit:        100,
  InvitationsLimit:    100,
  InvitationExpiresIn: 24 * time.Hour,
  RequireEmailVerifiedOnInvitation: true,
  DatabaseHooks: &organizationsplugintypes.OrganizationsDatabaseHooksConfig{
    // Optional database hooks for custom logic on organization lifecycle events
  },
})

API Reference

Organizations

HTTP MethodRoute PathDescription
POST/organizationsCreate organization
GET/organizationsList user's organizations
GET/organizations/{organization_id}Get organization
PATCH/organizations/{organization_id}Update organization
DELETE/organizations/{organization_id}Delete organization

Invitations

HTTP MethodRoute PathDescription
POST/organizations/{organization_id}/invitationsCreate invitation
GET/organizations/{organization_id}/invitationsList invitations
GET/organizations/{organization_id}/invitations/{invitation_id}Get invitation
PATCH/organizations/{organization_id}/invitations/{invitation_id}Revoke invitation
POST/organizations/{organization_id}/invitations/{invitation_id}/acceptAccept invitation
POST/organizations/{organization_id}/invitations/{invitation_id}/rejectReject invitation

Members

HTTP MethodRoute PathDescription
POST/organizations/{organization_id}/membersAdd member
GET/organizations/{organization_id}/membersList members
GET/organizations/{organization_id}/members/{member_id}Get member
PATCH/organizations/{organization_id}/members/{member_id}Update member
DELETE/organizations/{organization_id}/members/{member_id}Remove member

Teams

HTTP MethodRoute PathDescription
POST/organizations/{organization_id}/teamsCreate team
GET/organizations/{organization_id}/teamsList teams
PATCH/organizations/{organization_id}/teams/{team_id}Update team
DELETE/organizations/{organization_id}/teams/{team_id}Delete team

Team Members

HTTP MethodRoute PathDescription
POST/organizations/{organization_id}/teams/{team_id}/membersAdd member to team
GET/organizations/{organization_id}/teams/{team_id}/membersList team members
GET/organizations/{organization_id}/teams/{team_id}/members/{member_id}Get team member
DELETE/organizations/{organization_id}/teams/{team_id}/members/{member_id}Remove member from team

Database Schema

This plugin creates the following database tables:

Table: organizations

FieldTypeKeyDescription
idstringPKUnique identifier for the organization
owner_idstringFKReference to the organization owner (user)
namestring-Organization name
slugstring-URL-friendly organization identifier (unique)
logostring?-Organization logo URL
metadataJSON-Additional organization metadata
created_attimestamp-Record creation time
updated_attimestamp-Record last update time

Table: organization_invitations

FieldTypeKeyDescription
idstringPKUnique identifier for the invitation
emailstring-Email address being invited
inviter_idstringFKReference to the user who sent the invitation
organization_idstringFKReference to the organization
rolestring-Role assigned to the invited member
statusstring-Invitation status
expires_attimestamp-Invitation expiration time
created_attimestamp-Record creation time

Table: organization_members

FieldTypeKeyDescription
idstringPKUnique identifier for the member record
organization_idstringFKReference to the organization
user_idstringFKReference to the user
rolestring-Member's role within the organization
created_attimestamp-Record creation time
updated_attimestamp-Record last update time

Table: organization_teams

FieldTypeKeyDescription
idstringPKUnique identifier for the team
organization_idstringFKReference to the organization
namestring-Team name
slugstring-URL-friendly identifier
descriptionstring?-Description
metadataJSON-Additional metadata
created_attimestamp-Record creation time
updated_attimestamp-Record last update time

Table: organization_team_members

FieldTypeKeyDescription
idstringPKUnique identifier for the team member record
team_idstringFKReference to the team
member_idstringFKReference to the organization member
created_attimestamp-Record creation time

Migrations are automatically handled when the plugin is initialized.

Database Hooks

This plugin supports the following database hooks:

Organizations:

  • BeforeCreate: Before an organization is created
  • AfterCreate: After an organization is created
  • BeforeUpdate: Before an organization is updated
  • AfterUpdate: After an organization is updated
  • BeforeDelete: Before an organization is deleted
  • AfterDelete: After an organization is deleted

Invitations:

  • BeforeCreate: Before an invitation is created
  • AfterCreate: After an invitation is created
  • BeforeUpdate: Before an invitation is updated
  • AfterUpdate: After an invitation is updated
  • BeforeDelete: Before an invitation is deleted
  • AfterDelete: After an invitation is deleted

Members:

  • BeforeCreate: Before a member is created
  • AfterCreate: After a member is created
  • BeforeUpdate: Before a member is updated
  • AfterUpdate: After a member is updated
  • BeforeDelete: Before a member is deleted
  • AfterDelete: After a member is deleted

Teams:

  • BeforeCreate: Before a team is created
  • AfterCreate: After a team is created
  • BeforeUpdate: Before a team is updated
  • AfterUpdate: After a team is updated
  • BeforeDelete: Before a team is deleted
  • AfterDelete: After a team is deleted

Team Members:

  • BeforeCreate: Before a team member is created
  • AfterCreate: After a team member is created
  • BeforeDelete: Before a team member is deleted
  • AfterDelete: After a team member is deleted

NOTE

Database hooks are only supported in Library Mode.


Plugin Capabilities

This plugin doesn't provide any hooks and capabilities.


Security Recommendations

  • Ensure that the Access Control plugin is properly configured to manage permissions for organization-related actions.
  • Regularly review organization members and their roles to maintain proper access control.
  • Make sure to always require authentication for all organization-related API routes and enforce role-based access control for certain routes.

Client Plugin

If you're using the Authula SDK, add the plugin to the client instance as follows:

import { createClient } from "authula";
import { OrganizationsPlugin } from "authula/plugins";

export const authulaClient = createClient({
  url: "http://localhost:8080/auth",
  plugins: [new OrganizationsPlugin()],
});

On this page