|
1 | 1 | # Changelog
|
2 | 2 |
|
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 |
4 | 162 |
|
0 commit comments