Skip to content

Commit e49a834

Browse files
committed
Merge branch 'main' of github.com:codebar-ag/laravel-bexio
2 parents 7e2fb19 + 94ad298 commit e49a834

File tree

170 files changed

+2640
-683
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

170 files changed

+2640
-683
lines changed

.github/workflows/dependency-review.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ jobs:
1515
runs-on: ubuntu-latest
1616
steps:
1717
- name: 'Checkout Repository'
18-
uses: actions/checkout@v4
18+
uses: actions/checkout@v5
1919
- name: 'Dependency Review'
2020
uses: actions/dependency-review-action@v4

.github/workflows/fix-php-code-style-issues.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ jobs:
88

99
steps:
1010
- name: Checkout code
11-
uses: actions/checkout@v4
11+
uses: actions/checkout@v5
1212
with:
1313
ref: ${{ github.head_ref }}
1414

1515
- name: Fix PHP code style issues
16-
uses: aglipanci/laravel-pint-action@2.5
16+
uses: aglipanci/laravel-pint-action@2.6
1717

1818
- name: Commit changes
19-
uses: stefanzweifel/git-auto-commit-action@v5
19+
uses: stefanzweifel/git-auto-commit-action@v7
2020
with:
2121
commit_message: Fix styling

.github/workflows/phpstan.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
name: phpstan
88
runs-on: ubuntu-latest
99
steps:
10-
- uses: actions/checkout@v4
10+
- uses: actions/checkout@v5
1111

1212
- name: Setup PHP
1313
uses: shivammathur/setup-php@v2

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
name: Release
1212
runs-on: ubuntu-latest
1313
steps:
14-
- uses: actions/checkout@v4
14+
- uses: actions/checkout@v5
1515
with:
1616
fetch-depth: '0'
1717
- name: Bump version and push tag

.github/workflows/run-tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222

2323
steps:
2424
- name: Checkout code
25-
uses: actions/checkout@v4
25+
uses: actions/checkout@v5
2626

2727
- name: Setup PHP
2828
uses: shivammathur/setup-php@v2
@@ -49,7 +49,7 @@ jobs:
4949

5050
- name: Store Log Artifacts
5151
if: failure()
52-
uses: actions/upload-artifact@v4
52+
uses: actions/upload-artifact@v5
5353
with:
5454
name: Store report artifacts
5555
path: ./vendor/orchestra/testbench-core/laravel/storage/logs

.phpunit.cache/test-results

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

CHANGELOG.md

Lines changed: 159 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,162 @@
11
# Changelog
22

3-
All notable changes to `laravel-flatfox` will be documented in this file.
3+
All notable changes to `laravel-bexio` will be documented in this file.
4+
5+
## [Unreleased]
6+
7+
### 🚨 Breaking Changes
8+
9+
#### OAuth Implementation
10+
11+
**⚠️ MAJOR BREAKING CHANGES** - The authentication system has been completely redesigned to support OAuth alongside token authentication.
12+
13+
##### BexioConnector Constructor Changes
14+
15+
**Before (Token only):**
16+
```php
17+
// Old constructor - DEPRECATED
18+
$connector = new BexioConnector($token);
19+
$connector = new BexioConnector(); // Used config('bexio.auth.token')
20+
```
21+
22+
**After (OAuth + Token support):**
23+
```php
24+
// New constructor - REQUIRED
25+
use CodebarAg\Bexio\Dto\OAuthConfiguration\ConnectWithToken;
26+
use CodebarAg\Bexio\Dto\OAuthConfiguration\ConnectWithOAuth;
27+
28+
// Token authentication
29+
$connector = new BexioConnector(new ConnectWithToken($token));
30+
$connector = new BexioConnector(new ConnectWithToken()); // Uses config
31+
32+
// OAuth authentication
33+
$connector = new BexioConnector(new ConnectWithOAuth($clientId, $clientSecret, $redirectUri, $scopes));
34+
$connector = new BexioConnector(new ConnectWithOAuth()); // Uses config
35+
36+
// Auto-resolve from container (default behavior)
37+
$connector = new BexioConnector(); // Will resolve OAuth config if available
38+
```
39+
40+
##### Configuration Structure Changes
41+
42+
**Before:**
43+
```php
44+
// config/bexio.php
45+
return [
46+
'auth' => [
47+
'token' => env('BEXIO_API_TOKEN'),
48+
],
49+
];
50+
```
51+
52+
**After:**
53+
```php
54+
// config/bexio.php
55+
return [
56+
'auth' => [
57+
'token' => env('BEXIO_API_TOKEN'),
58+
'oauth' => [
59+
'client_id' => env('BEXIO_OAUTH_CLIENT_ID'),
60+
'client_secret' => env('BEXIO_OAUTH_CLIENT_SECRET'),
61+
'redirect_uri' => env('BEXIO_OAUTH_REDIRECT_URI'),
62+
'scopes' => explode(',', env('BEXIO_OAUTH_SCOPES')),
63+
],
64+
],
65+
'cache_store' => env('BEXIO_CACHE_STORE'),
66+
'route_prefix' => null,
67+
'redirect_url' => env('BEXIO_REDIRECT_URL', ''),
68+
];
69+
```
70+
71+
##### New Environment Variables Required
72+
73+
Add these new environment variables for OAuth support:
74+
75+
```dotenv
76+
# OAuth Authentication (NEW)
77+
BEXIO_OAUTH_CLIENT_ID=your_client_id_here
78+
BEXIO_OAUTH_CLIENT_SECRET=your_client_secret_here
79+
BEXIO_OAUTH_REDIRECT_URI=https://yourapp.com/bexio/callback
80+
BEXIO_OAUTH_SCOPES=openid,profile,email,accounting,contact_show
81+
82+
# Optional OAuth Configuration
83+
BEXIO_CACHE_STORE=redis
84+
BEXIO_REDIRECT_URL=/dashboard
85+
```
86+
87+
##### Service Provider Changes
88+
89+
- New OAuth resolver contracts are automatically registered
90+
- OAuth routes are automatically registered at `/bexio/redirect` and `/bexio/callback`
91+
- Route prefix can be customized via `config('bexio.route_prefix')`
92+
93+
##### Migration Guide
94+
95+
1. **Update your BexioConnector instantiation:**
96+
```php
97+
// OLD - This will break
98+
$connector = new BexioConnector($token);
99+
100+
// NEW - Required change
101+
$connector = new BexioConnector(new ConnectWithToken($token));
102+
```
103+
104+
2. **Publish and update config file:**
105+
```bash
106+
php artisan vendor:publish --provider="CodebarAg\Bexio\BexioServiceProvider" --tag="bexio-config" --force
107+
```
108+
109+
3. **For OAuth usage:**
110+
- Register your application in Bexio Developer Portal
111+
- Add OAuth environment variables to `.env`
112+
- Use `ConnectWithOAuth` for OAuth authentication
113+
- Use built-in routes `/bexio/redirect` and `/bexio/callback`
114+
115+
4. **For multi-tenant applications:**
116+
- Implement custom `BexioOAuthConfigResolver` interface
117+
- Implement custom `BexioOAuthAuthenticationStoreResolver` interface
118+
- Optionally implement custom `BexioOAuthAuthenticationValidateResolver` interface for validation logic
119+
- Bind your implementations in a service provider
120+
121+
### ✨ New Features
122+
123+
- **OAuth 2.0 Support**: Full OAuth 2.0 implementation with PKCE support
124+
- **Multi-tenant OAuth**: Support for multiple Bexio accounts via custom resolvers
125+
- **OAuth Authentication Validation**: Custom validation logic before storing OAuth tokens with API access and custom redirects
126+
- **Automatic Token Refresh**: OAuth tokens are automatically refreshed when expired
127+
- **Encrypted Token Storage**: OAuth tokens are encrypted when cached
128+
- **Built-in OAuth Routes**: Automatic OAuth flow handling
129+
- **Configurable Cache Stores**: Support for custom cache stores for token storage
130+
- **Comprehensive Scopes**: Support for all Bexio API and OpenID Connect scopes
131+
132+
#### OAuth Authentication Validation
133+
134+
The new `BexioOAuthAuthenticationValidateResolver` allows you to implement custom validation logic that runs after OAuth authentication but before the token is stored. This powerful feature provides:
135+
136+
- **API Access**: Full `BexioConnector` instance with authenticated access to Bexio API
137+
- **Custom Validation**: Validate user permissions, company restrictions, or any business logic
138+
- **Custom Redirects**: Return custom redirect responses with your own error handling
139+
- **Exception Handling**: Gracefully handle API errors during validation
140+
141+
**Example Use Cases:**
142+
- Validate user email against an allowlist
143+
- Check company permissions via Bexio API calls
144+
- Verify required OAuth scopes are present
145+
- Implement custom business rules for authorization
146+
147+
**Default Behavior**: By default, all OAuth authentications are accepted (validation returns success)
148+
149+
### 🔧 Configuration
150+
151+
- **New OAuth Configuration**: Complete OAuth configuration structure
152+
- **Route Customization**: Customizable OAuth route prefix
153+
- **Cache Store Configuration**: Configurable cache store for token storage
154+
- **Redirect URL Configuration**: Configurable post-authentication redirect
155+
156+
### 📚 Documentation
157+
158+
- **Updated README**: Comprehensive OAuth and multi-tenant documentation
159+
- **OAuth Validation Documentation**: Complete guide for custom OAuth authentication validation with examples
160+
- **Migration Examples**: Detailed migration examples for all scenarios
161+
- **Scope Documentation**: Complete OAuth scope enumeration and documentation
4162

0 commit comments

Comments
 (0)