This repository contains various examples of clients connecting to the Amtgard IDP.
examples/plain-php: A basic PHP implementation using raw cURL requests and manual OAuth flow handling.examples/phpleague-oauthclient: Implementation usingthephpleague/oauth2-clientand Slim 4.examples/svelte-spa: Single Page Application using Svelte and Vite.examples/react-spa: Single Page Application using React and Vite.
To test against a local development instance of amtgard-idp or the production environment, you may need to change the IDP URL.
- Local Development: To use a local instance of
amtgard-idprunning on port 37080, change the endpoint tohttp://localhost:37080. - Production: To use the live Amtgard IDP, change the endpoint to
https://idp.amtgard.com.
Each example has a different way of configuring the endpoint:
- plain-php: Modify the
$idpUrlvariable inexamples/plain-php/src/oauth.php. - phpleague-oauthclient: Modify the
idp_urlsetting in the application's configuration. - plain-jquery: Update the
proxy_passdirective inexamples/plain-jquery/nginx.conf. - react-spa: Update the
proxytarget inexamples/react-spa/vite.config.js. - svelte-spa: Update the
proxytarget inexamples/svelte-spa/vite.config.js.
To get a client_id and client_secret for testing, you can request one by posting in the Amtgard ORK Help group on Facebook.
The plain PHP example includes a docker-compose.yml file for easy deployment.
-
Navigate to the directory:
cd examples/plain-php -
Start the container:
docker-compose up -d
-
Access the application at http://localhost:37180.
- The application uses a local SQLite database (
database.sqlite) stored in theexamples/plain-phpdirectory. - Configuration (Client ID, IDP URL) is defined in
src/oauth.php.
This example uses Slim Framework 4 and league/oauth2-client.
-
Navigate to the directory:
cd examples/phpleague-oauthclient -
Start the container:
docker-compose up -d
-
Install dependencies (required first time):
docker-compose exec php composer install -
Access the application at http://localhost:37181.
- Uses port 37181 and Client ID
test_phpleague_oauth_client. - Authentication logic is in
src/AuthController.php.
This example is a Single Page Application using jQuery and standard browser APIs. It is hosted as static files via Nginx.
-
Navigate to the directory:
cd examples/plain-jquery -
Start the container:
docker-compose up -d
-
Access the application at http://localhost:37184.
- Uses port 37184 and Client ID
test_plain_jquery. - Nginx is configured to proxy
/api/oauthand/api/resourcesto the IDP to handle potential CORS issues during development.
This example uses React and Vite. It runs locally via the Vite dev server.
-
Navigate to the directory:
cd examples/react-spa -
Install dependencies:
npm install
-
Start the dev server:
npm run dev
-
Access the application at http://localhost:37183.
- Uses port 37183 and Client ID
test_react_spa. - Vite is configured to proxy
/api/oauthand/api/resourcestohttps://idp.amtgard.com.
This example uses Svelte and Vite. It runs locally via the Vite dev server.
-
Navigate to the directory:
cd examples/svelte-spa -
Install dependencies:
npm install
-
Start the dev server:
npm run dev
-
Access the application at http://localhost:37182.
- Uses port 37182 and Client ID
test_svelte_spa. - Vite is configured to proxy
/api/oauthand/api/resourcestohttps://idp.amtgard.com.