Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
a34f383
feat(auth): add RoleAffiliatedIdsServiceTest
herpaderpaldent Jul 31, 2024
781cfa6
feat(auth): add RolePermissionObjectService and test
herpaderpaldent Jul 31, 2024
dc15d97
feat: add tests for UserPermissionService and implement UserPermissio…
herpaderpaldent Jul 31, 2024
f635093
chore(tests): add ArchitectureTest.php with debugs removed
herpaderpaldent Aug 1, 2024
0c9e717
chore(tests): add Role variable declaration in RolePermissionObjectSe…
herpaderpaldent Aug 1, 2024
29913f9
feat: Add new CanUserService class for handling user permissions and …
herpaderpaldent Aug 1, 2024
5a45961
feat: refactor SSO routes and controllers
herpaderpaldent Aug 2, 2024
e396422
feat: Implement IsUserCompliantService to check user compliance with …
herpaderpaldent Aug 2, 2024
a3569f2
feat: Add RoleRequestTest and RoleRequest for validation of role requ…
herpaderpaldent Aug 2, 2024
ef39e14
feat: Add AutomaticRoleServiceTest and AutomaticRoleService classes a…
herpaderpaldent Aug 2, 2024
22a16cf
wip
herpaderpaldent Aug 7, 2024
052d728
feat(auth): refactor BaseRoleService to use match expression
herpaderpaldent Aug 7, 2024
f884aed
feat(models): remove affiliatedIds method in Role model (#123)
herpaderpaldent Aug 7, 2024
aba54dd
lint
herpaderpaldent Aug 7, 2024
ff31122
feat(sso): update scope building for user's corporations and alliances
herpaderpaldent Aug 7, 2024
25da052
refactor: update login method to use Auth facade and handle exception…
herpaderpaldent Aug 7, 2024
f70b229
feat: Update cache key structure for user permissions in SsoScopeObse…
herpaderpaldent Aug 8, 2024
5d0bbec
feat(observers): update ApplicationObserver to handle different appli…
herpaderpaldent Aug 8, 2024
33921c1
feat(auth): Add method to update member status based on user compliance
herpaderpaldent Aug 8, 2024
dae496c
feat(auth): add on request role service
herpaderpaldent Aug 9, 2024
2c18b38
feat(auth): add ManualRoleService and ManualRoleServiceTest
herpaderpaldent Aug 9, 2024
8fd42b7
chore(auth): refactor setRoleMembership method in AbstractRoleService
herpaderpaldent Aug 9, 2024
b9e842a
chore(auth): refactor AbstractRoleService method names and add new cr…
herpaderpaldent Aug 9, 2024
26ea612
chore(auth): update addCriteria method signature and refactor assignm…
herpaderpaldent Aug 9, 2024
ff5fef3
feat(auth): add OptInRoleService class and OptInRoleServiceTest
herpaderpaldent Aug 9, 2024
9aabcd4
feat(auth): add new methods for handling role types
herpaderpaldent Aug 9, 2024
8820daf
feat(role): implement automatic role assignment to corporation and al…
herpaderpaldent Aug 9, 2024
d1f6a27
feat: refactor getRoleMembers method in AbstractRoleService class
herpaderpaldent Aug 9, 2024
3420f63
feat: added canView, canJoin, and canModerate methods to BaseRoleServ…
herpaderpaldent Aug 12, 2024
ce8956a
feat: added canView and canJoin methods to RoleServiceInterface
herpaderpaldent Aug 25, 2024
14b2a22
feat: add ManageAutomaticRoleAction and test
herpaderpaldent Aug 25, 2024
4d0ec3f
feat: add SetModeratorAction and test.
herpaderpaldent Aug 25, 2024
afcd1e5
feat: add AddModeratorRoleAction and test.
herpaderpaldent Aug 25, 2024
8ebe9c6
feat: add RemoveModeratorRoleAction and test.
herpaderpaldent Aug 25, 2024
67ebd09
feat: add LoginAssetActionTest to test login page assets.
herpaderpaldent Aug 25, 2024
a13f455
refactor LogoutAction to use auth() helper and session() helper.
herpaderpaldent Aug 25, 2024
d907c5a
Add CharacterUserTest.php
herpaderpaldent Aug 25, 2024
e60c5d6
Remove unnecessary imports and dependencies in LogoutActionTest.
herpaderpaldent Aug 25, 2024
e9c10e0
Add RoleMembershipTest.php with role relationship test.
herpaderpaldent Aug 25, 2024
73fa61d
Add unit test and action for adding a member role.
herpaderpaldent Aug 27, 2024
1ca86a7
Add ManageManualRoleActionTest and ManageManualRoleAction files.
herpaderpaldent Aug 27, 2024
8dc4db3
Add RemoveMemberAction class and test case.
herpaderpaldent Aug 27, 2024
4f0bc4c
Add SetMemberAction and SetMemberActionTest for role manipulation.
herpaderpaldent Aug 27, 2024
709adb4
Remove dump statement and improve test readability.
herpaderpaldent Sep 2, 2024
c997b1a
Add ApplyAction class for applying roles on user requests.
herpaderpaldent Sep 2, 2024
5388bbb
Add ApproveAction class for approving role applications.
herpaderpaldent Sep 3, 2024
10d48a8
Add DenyActionTest and DenyAction files for denying role application.
herpaderpaldent Sep 3, 2024
19f1c03
Create ManageOnRequestRoleActionTest and ManageOnRequestRoleAction fi…
herpaderpaldent Sep 3, 2024
6bdf283
Create OptOutActionTest to test opt out functionality.
herpaderpaldent Sep 4, 2024
5559d71
Add JoinActionTest and JoinAction files for testing the join action f…
herpaderpaldent Sep 4, 2024
65f4d05
Add LeaveAction class and LeaveActionTest unit tests.
herpaderpaldent Sep 9, 2024
b68f6f6
Add ManageOptInRoleAction and ManageOptInRoleActionTest files.
herpaderpaldent Sep 9, 2024
d063d7a
Remove unused import for RoleMembership.
herpaderpaldent Sep 9, 2024
03ee284
Add validation rule for 'name' field in RoleRequest.
herpaderpaldent Sep 9, 2024
86f0cc0
add test for redirectTo test
herpaderpaldent Sep 10, 2024
7ddf8b0
Add test for building provider with valid config in AuthenticationSer…
herpaderpaldent Sep 10, 2024
060da4f
Add AuthenticationService with methods for logging in, setting intend…
herpaderpaldent Sep 13, 2024
b9de64d
Add AuthenticationService dependency injection in CallbackController.
herpaderpaldent Sep 13, 2024
95cbc2e
Add method to retrieve previous URL from session in AuthenticationSer…
herpaderpaldent Sep 13, 2024
acf0182
Refactor RedirectSSOController to use AuthenticationService for authe…
herpaderpaldent Sep 13, 2024
5f7c507
Refactor RedirectSSOController for authentication in StepUpTest.
herpaderpaldent Sep 13, 2024
11ccb2e
Refactor RoleMemberSync for authentication in StepUpTest.
herpaderpaldent Sep 13, 2024
3102fae
Lint: linting
herpaderpaldent Sep 13, 2024
48f8a8a
refactor to improve static analysis
herpaderpaldent Sep 14, 2024
2958da4
lint and baseline
herpaderpaldent Sep 14, 2024
08a9175
Refactor: Specify return types for methods in AbstractRoleService.
herpaderpaldent Sep 14, 2024
b9c3fc6
lint
herpaderpaldent Jan 4, 2025
f75d33c
upgrade dependencies for L11 and eveapi 4
herpaderpaldent Jan 5, 2025
f222d8b
Remove unnecessary method call for registering permissions
herpaderpaldent Jan 5, 2025
eb89afc
remove potentially duplicated character_roles
herpaderpaldent Jan 5, 2025
c6a4623
migrate to latest permission config
herpaderpaldent Jan 5, 2025
1e890ac
Add PermissionServiceProvider to the list of service providers.
herpaderpaldent Jan 5, 2025
676bc81
Refactor the faker function to remove redundant code.
herpaderpaldent Jan 5, 2025
6034f9a
refactor test
herpaderpaldent Jan 5, 2025
1556710
Add admin permission variable and check user permissions.
herpaderpaldent Jan 5, 2025
fd0d0bb
Delete existing character roles before creating a new one.
herpaderpaldent Jan 5, 2025
5a4ebb7
lint with pint
herpaderpaldent Jan 5, 2025
1bd6d82
Refactor UserPermissionService.php to handle empty roles array.
herpaderpaldent Jan 5, 2025
5b58858
Update github actions
herpaderpaldent Jan 5, 2025
27b52c0
Update UserFactory.php (#400)
herpaderpaldent Apr 22, 2025
568c0d7
Improvement/role type casting (#401)
herpaderpaldent Apr 27, 2025
1b7da67
Set custom permission models in authentication config
herpaderpaldent May 22, 2025
f433f53
fix: widen redirectTo return type to allow Inertia\Response overrides
herpaderpaldent Apr 24, 2026
ba829e4
refactor: replace positional tuples with readonly DTOs (AffiliationDa…
herpaderpaldent Apr 29, 2026
ebc2445
fix: eager load entity relation in updateMemberStatusBasedOnUserCompl…
herpaderpaldent May 4, 2026
5d4d12e
feat: allow moderators on opt-in roles
herpaderpaldent May 7, 2026
cd4e2f5
fix: redirect to / instead of throwing when user is already authentic…
herpaderpaldent May 8, 2026
4cdd9b2
chore: upgrade to PHP 8.5 and Laravel 13
herpaderpaldent May 12, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 0 additions & 32 deletions .github/workflows/check-coding-standards.yml

This file was deleted.

74 changes: 74 additions & 0 deletions .github/workflows/laravel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: CI

on:
push:
branches: [ 3.x, 4.x ]
pull_request:
branches: [ 3.x, 4.x ]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
laravel:
runs-on: ubuntu-latest

services:
postgres:
image: postgres:17
env:
POSTGRES_USER: seatplus
POSTGRES_PASSWORD: secret
POSTGRES_DB: laravel
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5

redis:
image: redis:7
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5

steps:
- uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
extensions: mbstring, dom, fileinfo, pgsql, pdo_pgsql, redis
coverage: xdebug

- name: Cache Composer dependencies
uses: actions/cache@v4
with:
path: vendor
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install Dependencies
run: composer install --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist

- name: Check Coding Standards
run: composer run test:lint

- name: Static Analysis
run: composer run test:types

- name: Type Coverage
run: composer run test:type-coverage

- name: Run Tests
env:
XDEBUG_MODE: coverage
run: vendor/bin/pest --coverage --min=100 --colors=always
42 changes: 0 additions & 42 deletions .github/workflows/tests.yml

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ build/
.php_cs
.php_cs.cache
.phpunit.result.cache
.phpunit.cache
.php-cs-fixer.cache

28 changes: 28 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

Upgrading to this version will require you to update your `auth` package to `^4.0.0`.
You are required to implement the `auth.login` and `auth.login` routes in your application. The `LoginController` and `LogoutController` have been removed from the package.


### Added
- Introduced LoginAssetAction to serve login assets
- Introduced LogoutAction to serve logout assets

### Changed
- Switching main character has changed to use `PUT: auth/main-character/switch/{new_character_id}`. The correct route parameters are now required.

### Fixed

### Removed
- Removed login controller and route
- Removed logout controller and route

## [4.0.0] - 2024-09-01
### Added
90 changes: 83 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,87 @@
# auth
handels authentication for web and eveapi
# seatplus/auth

# Usage
[![CI](https://github.com/seatplus/auth/actions/workflows/laravel.yml/badge.svg)](https://github.com/seatplus/auth/actions/workflows/laravel.yml)

## Add more scopes
By default the minimal scopes are requested for users. However one might add scopes to an existing user by adding
a query parameters stating comma separated which scopes should be add:
Handles authentication, authorisation, and SSO scope compliance for the seatplus EVE Online management platform. This is the core package — `seatplus/eveapi` and `seatplus/web` both depend on it.

## Overview

### Role system

Four role types with distinct membership and permission semantics:

| Type | Membership | Use case |
|------|-----------|---------|
| `automatic` | Auto-assigned when a character belongs to a configured corporation or alliance | Fleet / alliance access |
| `on-request` | User applies, moderator approves or denies | Corp-specific elevated access |
| `manual` | Admin explicitly adds / removes individual users | One-off grants |
| `opt-in` | User self-joins if they meet the criteria | Opt-in programmes |

### Affiliation system

Every role has `Affiliation` records that define **permission scope** (which EVE entities the role holder can access data for), not membership. Three types:

- `allowed` — these corporations / alliances / characters are in scope
- `inverse` — everyone *except* these is in scope
- `forbidden` — always excluded, overrides `allowed` / `inverse`

### SSO scope compliance

`IsUserCompliantService` checks whether every character owned by a user has all required OAuth scopes. Required scopes are aggregated from global settings, corporation-level `SsoScopes` records, and alliance-level records. Non-compliant users have their role memberships set to `inactive` automatically on the next `handleMembers()` call.

### Permission checking

`CanUserService::check()` runs a Laravel Pipeline to validate a set of EVE entity IDs against a user's permissions. The pipeline strips IDs the user owns, IDs covered by in-game corporation roles (e.g. Director), and IDs covered by Spatie permissions. Any remaining IDs are denied. The `superuser` permission bypasses all checks.

## Installation

```bash
composer require seatplus/auth
```

Publish and run migrations:

```bash
php artisan vendor:publish --provider="Seatplus\Auth\AuthServiceProvider"
php artisan migrate
```
/eve/sso/{character_id?}/step_up?add_scopes=scope1,scope2

## Usage

### Add OAuth scopes to a character

By default the minimal scopes are requested. To step up a character to additional scopes, redirect to:

```
/eve/sso/{character_id}/step_up?add_scopes=esi-skills.read_skills.v1,esi-wallet.read_character_wallet.v1
```

### Check permissions

```php
use Seatplus\Auth\Services\Dtos\ValidateIdsDTO;
use Seatplus\Auth\Services\CanUserService;

$dto = ValidateIdsDTO::make(entity_ids: [12345678], user: $user);
CanUserService::check($user, $dto, permissions: ['view member tracking']);
```

## Development

### Requirements

- PHP 8.3+
- PostgreSQL (user `seatplus`, password `secret`, database `laravel` @ `127.0.0.1:5432`)
- Redis @ `127.0.0.1:6379`

### Running the test suite

```bash
composer run test # lint + PHPStan + type-coverage + unit tests
composer run test:unit # unit tests only
composer run test:lint # Pint formatting check
composer run lint # auto-fix formatting with Pint
composer run test:types # PHPStan static analysis
composer run test:type-coverage # 100% type coverage check
```

50 changes: 36 additions & 14 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,33 +15,49 @@
"Seatplus\\Auth\\Database\\Factories\\": "database/factories/"
},
"files": [
"src/Helpers/helpers.php"
]
},
"autoload-dev": {
"psr-4": {
"Seatplus\\Auth\\Tests\\": "tests/"
}
},
"minimum-stability": "stable",
"minimum-stability": "dev",
"prefer-stable": true,
"repositories": [
{
"type": "vcs",
"url": "https://github.com/seatplus/eveapi.git"
},
{
"type": "vcs",
"url": "https://github.com/seatplus/esi-client.git"
},
{
"type": "vcs",
"url": "https://github.com/seatplus/esi-schema.git"
}
],
"require": {
"php": "^8.1",
"laravel/framework": "^10.0",
"php": "^8.5",
"laravel/framework": "^13.0",
"laravel/socialite": "^5.0",
"seatplus/eveapi": "^3.0",
"spatie/laravel-permission": "^5.4",
"seatplus/eveapi": "dev-chore/laravel-13-upgrade as 4.1.0",
"seatplus/esi-client": "dev-chore/php-8.5-upgrade as 4.1.0",
"spatie/laravel-permission": "^6.10",
"socialiteproviders/eveonline": "^4.0"
},
"require-dev": {
"orchestra/testbench": "^8.0",
"nunomaduro/collision": "^7.0",
"pestphp/pest": "^2.0",
"pestphp/pest-plugin-laravel": "^2.0",
"rector/rector": "^0.15.21",
"driftingly/rector-laravel": "^0.17.0",
"larastan/larastan": "^2.9",
"pestphp/pest-plugin-type-coverage": "^2.8"
"orchestra/testbench": "^11.0",
"nunomaduro/collision": "^8.1",
"pestphp/pest": "^4.0",
"pestphp/pest-plugin-laravel": "^4.1",
"pestphp/pest-plugin-type-coverage": "^4.0",
"phpstan/phpstan": "^2.0",
"rector/rector": "^2.0",
"driftingly/rector-laravel": "^2.0",
"larastan/larastan": "^3.0",
"laravel/pint": "^1.9"
},
"extra": {
"laravel": {
Expand All @@ -67,6 +83,12 @@
"config": {
"allow-plugins": {
"pestphp/pest-plugin": true
},
"audit": {
"ignore": [
"PKSA-y2cr-5h3j-g3ys",
"PKSA-2kqm-ps5x-s4f5"
]
}
}
}
6 changes: 6 additions & 0 deletions config/auth.permissions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php

return [
'administrate access control groups',
'view access control groups',
];
4 changes: 2 additions & 2 deletions config/auth.updateJobs.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
* SOFTWARE.
*/

use Seatplus\Auth\Jobs\DispatchUserRoleSync;
use Seatplus\Auth\Jobs\RoleMemberSync;

return [
DispatchUserRoleSync::class,
RoleMemberSync::class,
];
Loading
Loading