Skip to content

Commit a162857

Browse files
authored
bump dependencies (#2)
1 parent d09d003 commit a162857

File tree

4 files changed

+176
-14
lines changed

4 files changed

+176
-14
lines changed

.github/workflows/run-tests.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,16 @@ jobs:
1717
fail-fast: true
1818
matrix:
1919
os: [ubuntu-latest, windows-latest]
20-
php: [8.3, 8.2]
21-
laravel: [11.*]
20+
php: [8.3, 8.4]
21+
laravel: [11.*, 12.*]
2222
stability: [prefer-lowest, prefer-stable]
2323
include:
2424
- laravel: 11.*
2525
testbench: 9.*
2626
carbon: ^2.63
27+
- laravel: 12.*
28+
testbench: 10.*
29+
carbon: ^3.0
2730

2831
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}
2932

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
build
44
composer.lock
55
coverage
6-
docs
76
phpunit.xml
87
phpstan.neon
98
testbench.yaml
@@ -15,4 +14,4 @@ sign.sh
1514
test.sig
1615
test
1716
hash-key
18-
gen_key.sh
17+
gen_key.sh

composer.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@
44
"homepage": "https://github.com/LycheeOrg/verify",
55
"license": "MIT",
66
"require": {
7-
"php": "^8.2",
8-
"illuminate/contracts": "^11.0",
9-
"thecodingmachine/safe": "^2.5"
7+
"php": "^8.3",
8+
"illuminate/contracts": "^12.0||^11.0",
9+
"thecodingmachine/safe": "^3.3"
1010
},
1111
"require-dev": {
12-
"nunomaduro/collision": "^8.3",
13-
"larastan/larastan": "^2.9",
14-
"orchestra/testbench": "^9.0.0||^8.22.0",
12+
"nunomaduro/collision": "^8.8",
13+
"larastan/larastan": "^3.6",
14+
"orchestra/testbench": "^10.0.0||^9.0.0||^8.22.0",
1515
"friendsofphp/php-cs-fixer": "^3.3",
16-
"lychee-org/phpstan-lychee": "^v1.0.1",
17-
"php-parallel-lint/php-parallel-lint": "^1.3",
18-
"phpunit/phpunit": "^10.0"
16+
"lychee-org/phpstan-lychee": "^v2.0.2",
17+
"php-parallel-lint/php-parallel-lint": "^1.4",
18+
"phpunit/phpunit": "^10.0||^11.0"
1919
},
2020
"autoload": {
2121
"psr-4": {
@@ -47,7 +47,7 @@
4747
},
4848
"config": {
4949
"platform": {
50-
"php": "8.2"
50+
"php": "8.3"
5151
},
5252
"sort-packages": true,
5353
"allow-plugins": {

docs/README.md

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
# Verify - Architecture Documentation
2+
3+
Verify is the License management system used by Lychee to validate license keys. It provides a flexible architecture for validating licenses through either hash-based validation or cryptographic signature validation.
4+
5+
## Core Architecture
6+
7+
### Overall Structure
8+
9+
```
10+
src/
11+
├── Contract/ # Core interfaces and enums
12+
│ ├── Status.php # License status types
13+
│ ├── ValidatorInterface.php # Validator contract
14+
│ └── VerifyInterface.php # Core verification contract
15+
├── Exceptions/ # Custom exceptions
16+
│ ├── BaseVerifyException.php
17+
│ └── SupporterOnlyOperationException.php
18+
├── Facades/ # Laravel facades
19+
│ └── VerifyFacade.php
20+
├── Http/ # HTTP components
21+
│ └── Middleware/ # Middleware for route protection
22+
├── Validators/ # License validation implementations
23+
│ ├── ValidateHash.php # Hash-based validation
24+
│ └── ValidateSignature.php # Cryptographic signature validation
25+
├── Verify.php # Main verification class
26+
└── VerifyServiceProvider.php # Laravel service provider
27+
```
28+
29+
### Component Description
30+
31+
#### 1. Status System
32+
33+
The license status is represented by the `Status` enum, which defines three levels:
34+
35+
- `FREE_EDITION` - Basic features, no license required
36+
- `SUPPORTER_EDITION` - Standard supporter features
37+
- `PLUS_EDITION` - Premium features with extended capabilities
38+
39+
#### 2. Validation Mechanism
40+
41+
The plugin implements a strategy pattern for license validation through the `ValidatorInterface`:
42+
43+
```php
44+
interface ValidatorInterface
45+
{
46+
public function validate(string $verifiable, string $license): bool;
47+
public function grant(): Status;
48+
}
49+
```
50+
51+
Two concrete validators are provided:
52+
53+
1. **ValidateHash** - Uses password hashing to validate a static license key
54+
- Returns `SUPPORTER_EDITION` status when valid
55+
- Simple validation mechanism for standard supporters
56+
57+
2. **ValidateSignature** - Uses cryptographic signatures for validation
58+
- Returns `PLUS_EDITION` status when valid
59+
- More secure mechanism for premium users
60+
- Uses asymmetric cryptography (ECDSA) for verification
61+
62+
#### 3. Core Verify Class
63+
64+
The `Verify` class serves as the central hub and implements `VerifyInterface`. It:
65+
66+
- Coordinates between different validators
67+
- Provides convenience methods for checking license status
68+
- Handles authorization logic
69+
- Provides conditional execution based on license status
70+
71+
#### 4. Service Provider & Integration
72+
73+
The `VerifyServiceProvider` handles Laravel integration by:
74+
- Registering the Verify service in the Laravel container
75+
- Merging configuration files
76+
- Making the service available through the facade
77+
78+
#### 5. Facade
79+
80+
The `VerifyFacade` provides a static interface to access the Verify functionality, following the Laravel facade pattern.
81+
82+
## Usage Examples
83+
84+
### Basic Verification
85+
86+
```php
87+
// Check if the user is a supporter
88+
if ($verify->is_supporter()) {
89+
// Provide supporter features
90+
}
91+
92+
// Check if the user has premium status
93+
if ($verify->is_plus()) {
94+
// Provide premium features
95+
}
96+
```
97+
98+
### Authorization
99+
100+
```php
101+
// Will throw SupporterOnlyOperationException if not a supporter
102+
$verify->authorize();
103+
104+
// Will throw exception if not a plus user
105+
$verify->authorize(Status::PLUS_EDITION);
106+
```
107+
108+
### Conditional Execution
109+
110+
```php
111+
$result = $verify->when(
112+
fn() => 'Supporter feature enabled!',
113+
fn() => 'Please upgrade to supporter edition.',
114+
Status::SUPPORTER_EDITION
115+
);
116+
```
117+
118+
## Configuration
119+
120+
Configuration is stored in `config/verify.php`, which includes:
121+
122+
- Validation configuration for integrity checks
123+
- Public keys and hash settings (in the actual implementation)
124+
125+
## Database Integration
126+
127+
The plugin uses the database to store:
128+
- License keys
129+
- User emails associated with licenses
130+
131+
These are stored in the `configs` table with dedicated migration files.
132+
133+
## Security Considerations
134+
135+
The plugin implements multiple layers of security:
136+
1. Hash-based validation for supporter licenses
137+
2. Cryptographic signature validation for premium licenses
138+
3. Server-side validation to prevent client-side tampering
139+
4. Integrity checking of core verification files
140+
141+
## Extension Points
142+
143+
The architecture allows extending the system by:
144+
1. Creating new validators implementing `ValidatorInterface`
145+
2. Adding additional status levels to the `Status` enum
146+
3. Creating custom middleware for specific route protection
147+
148+
## Integrity Validation
149+
150+
The system includes a self-validation mechanism that verifies the integrity of core verification files to detect tampering:
151+
152+
```php
153+
if ($verify->validate()) {
154+
// System is intact
155+
} else {
156+
// Core files have been tampered with
157+
}
158+
```
159+
160+
This system compares file checksums against expected values to ensure the verification system itself hasn't been compromised.

0 commit comments

Comments
 (0)