autokz/oauth_proxy

Proxy server for Auth with JWT

1.1.4 2021-03-15 09:36 UTC

This package is not auto-updated.

Last update: 2024-04-26 00:55:51 UTC


README

alt text

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"