autokz / oauth_proxy
Proxy server for Auth with JWT
1.1.4
2021-03-15 09:36 UTC
Requires
- php: >=7.4.0
- ext-json: *
- guzzlehttp/guzzle: ^7.2
- vlucas/phpdotenv: ^5.2
- webmozart/assert: ^1.9
Requires (Dev)
- overtrue/phplint: ^2.3
- phpunit/phpunit: ^9.5
- roave/security-advisories: dev-latest
- squizlabs/php_codesniffer: ^3.5
README
Init
<?php $converter = new JWTConverter(); $configStorage = new DotEnvConfigStorage(__DIR__ . '/../'); // Path to .env file $configStorage->load(); // Optional variable - Http client $httpClient = new CurlHttpClient();
Create Proxy
$proxy = new Proxy($converter, $configStore, $httpClient);
Methods
// Login $username = new UsernameType('username'); $password = new PasswordType('password'); $oAuthData = $proxy->login($username, $password); // string|Exception // Logout $oAuthData = 'crypted_and_converted_access_token_array_to_string'; $proxy->logout($oAuthData); // true|Exception // Check $oAuthData = 'crypted_and_converted_access_token_array_to_string'; $oAuthData = $proxy->check($oAuthData); // string|Exception // Refresh $oAuthData = 'crypted_and_converted_refresh_token_array_to_string'; $oAuthData = $proxy->refresh($oAuthData); // string|Exception
.env example
OAUTH_BASE_URL="http://0.0.0.0:8080" OAUTH_TYPE="Bearer" OAUTH_URL="oauth/auth" OAUTH_CHECK_URL="oauth/user/check" OAUTH_LOGOUT_URL="oauth/user/logout" OAUTH_GRANT_TYPE="password_domain" OAUTH_REFRESH_GRANT_TYPE="refresh_domain" OAUTH_DOMAIN="test.com" OAUTH_CLIENT_ID="app" OAUTH_CLIENT_SECRET="" OAUTH_ACCESS_TYPE="offline"