Download the PHP package andmarruda/authmodule without Composer

On this page you can find all versions of the php package andmarruda/authmodule. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package authmodule

AuthModule

A self-contained Laravel module for invitation-based user registration with audit logging. Built with Clean Architecture (Ports & Adapters), making it easy to swap implementations without touching business logic.

Features

Architecture

Requirements

Installation

1. Install via Composer

2. Register the service provider

For Laravel 11+, the provider is auto-discovered via Composer.

If auto-discovery is disabled in your app, add the provider manually in bootstrap/providers.php:

The service provider automatically:

3. Run migrations

This creates module tables such as invitations, teams, team_user, team_invitations, auth_audit_logs, otps, and user_preferences, plus updates users when needed.

Note: The module ships its own users table migration. If your project already has one, remove or adjust the module's 2026_02_15_100000_create_users_table.php migration to avoid conflicts. Upgrade note: If you already applied an older team_invitations migration with invited_by, run the package upgrade migration (2026_02_20_101100_migrate_team_invitations_to_morphable_inviter.php) to migrate to inviter_type/inviter_id and remove the legacy column.

4. Configure the invitation URL

Invitation emails include a link pointing to your frontend. Set the base URL in your .env:

The generated link format is: {FRONTEND_URL}/invitations/accept?token={TOKEN}

Falls back to APP_URL if FRONTEND_URL is not set.

5. Configure mail and queue

Make sure your mail driver and queue worker are properly configured so invitation emails are sent:

Usage

API Endpoints

Method URI Description Auth
POST /invitations/create Create an invitation Yes (manager only)
POST /invitations/accept Accept an invitation No
POST /users/register Register via invitation token No
POST /auth/jwt/token Issue JWT token from email/password No
POST /teams Create a new team Yes
GET /teams/mine List current user teams Yes
POST /teams/invitations/create Invite user to team Yes
GET /teams/invitations/resolve?token=... Resolve invitation and detect account existence No
POST /teams/invitations/redeem Redeem invitation (existing user path) Optional auth
POST /teams/invitations/register Register from team invitation (new user path) No
GET /auth/social/{provider}/redirect Start OAuth login (google, github) No
GET /auth/social/{provider}/callback OAuth callback No
GET /auth/social/profile/status Get missing profile fields after social auth Yes
POST /auth/social/profile/complete Complete missing profile data Yes

Create an invitation (manager only)

Responses:

Accept an invitation

Responses:

Register a new user

Responses:

Typical flow

Social login (Google/GitHub)

This package supports google and github with Laravel Socialite.

  1. Add provider credentials to your .env:

  2. Configure config/services.php in your Laravel app:

  3. (Optional) publish and tune package config:

config/authmodule.php lets you customize allowed providers, scopes, and post-login/error redirects.

For onboarding after social login, configure:

  1. Manual test flow:

  2. (Optional) Protect app routes until profile is complete:

Creating a manager

The first manager must be created manually (via tinker, a seeder, or a direct DB update):

From there, managers can invite other users through the API.

Customization

Session + Sanctum

The package supports web (session) and sanctum (API token) at the same time.

Publish config and set guards per route group:

By default, protected endpoints accept both session (web) and API token (sanctum) authentication. If you enable sanctum guards, install/configure Sanctum in the host app. When creating team invitations, send inviter_type (user/tenant) and inviter_id if you want a non-user inviter context. The default authorizer only allows the authenticated user to be the inviter; provide your own authorizer class to validate tenant contexts.

JWT (native)

You can also use the built-in jwt guard for bearer authentication. Default algorithm is RS256 (recommended for multi-client/mobile/public API scenarios). EdDSA (Ed25519) is also supported when libsodium is available.

Configuration keys:

Minimal .env for RS256:

For EdDSA, set AUTHMODULE_JWT_ALGORITHM=EdDSA and provide base64 keys:

Token endpoint:

Generate EdDSA keys + ready-to-use env file:

Useful options:

The command creates:

If ext-sodium is not available, the command exits with guidance to install/enable it.

Swapping implementations

The module uses interface bindings, so you can replace any implementation. Override the bindings in your own service provider:

Available interfaces:

Interface Default Implementation Purpose
UserRepositoryInterface EloquentUserRepository User persistence
InvitationRepositoryInterface EloquentInvitationRepository Invitation persistence
TokenGeneratorInterface SecureTokenGenerator Token generation
AuditLoggerInterface EloquentAuditLogger Audit logging
InvitationMailerInterface MailInvitationMailer Sending invitation emails

Publishing views

To customize the invitation email template, copy the view to your project's resources:

Laravel will automatically use the vendor override.

Testing

The module includes both unit and feature tests.

Running tests

Test coverage

Unit tests (mocked dependencies):

Feature tests (full HTTP with database):

Using factories in your own tests

Database schema

users

Column Type Notes
id bigint PK
name string
email string unique
password string hashed
is_manager boolean default false
email_verified_at timestamp nullable
remember_token string nullable
created_at / updated_at timestamps

invitations

Column Type Notes
id bigint PK
email string indexed with accepted_at
token string(64) unique
invited_by FK -> users cascade on delete
resource_scope string nullable
expires_at timestamp default: 7 days from creation
accepted_at timestamp nullable
created_at / updated_at timestamps

auth_audit_logs

Column Type Notes
id bigint PK
action string invitation_created, invitation_accepted, user_registered
actor_id FK -> users nullable, null on delete
actor_email string nullable
target_email string nullable
invitation_id FK -> invitations nullable, null on delete
resource_scope string nullable
metadata json nullable
ip_address string nullable
user_agent text nullable
created_at timestamp

teams

Column Type Notes
id bigint PK
name string
slug string unique
owner_id FK -> users cascade on delete
created_at / updated_at timestamps

team_user

Column Type Notes
id bigint PK
team_id FK -> teams cascade on delete
user_id FK -> users cascade on delete
role string default member
joined_at timestamp nullable
created_at / updated_at timestamps

team_invitations

Column Type Notes
id bigint PK
team_id FK -> teams cascade on delete
email string indexed with accepted_at
token string(64) unique
inviter_type string morph type (User, Tenant, etc.)
inviter_id bigint morph id
role string default member
expires_at timestamp
accepted_at timestamp nullable
created_at / updated_at timestamps

License

This module is part of the Novos Horizontes project.


All versions of authmodule with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
ext-openssl Version *
andmarruda/authorization-module Version >=0.0.1
illuminate/auth Version >=10.0
illuminate/mail Version >=10.0
illuminate/database Version >=10.0
illuminate/routing Version >=10.0
illuminate/support Version >=10.0
illuminate/queue Version >=10.0
laravel/socialite Version ^5.18
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package andmarruda/authmodule contains the following files

Loading the files please wait ...