A simple middleware written in Slim PHP, that takes care of the authentication for API users connecting to the POWER platform from the POWER React app, that is deployed on a University website.
The whole project consists of the following applications:
-
POWER project website: Contains general information about the project, events, applications, articles. It is independent from the platforms discussed below.
-
POWER platform: Company representatives can post and Institution representatives can review placement opportunities on this site. This site stores the job offer and user data and provides the API, that exposes accepted placement opportunities to Institutions through the middleware below.
-
POWER React Application: The application, that Institutions can include into their websites. This application connects to the middleware, which handles authentication
-
POWER middleware: EUF provides two middleware solutions in the POWER project.
- NodeJS based middleware: If you'd like to use a middleware solution developed in NodeJS instead, visit this project
- PHP Slim based middleware: This is the repository you're currently viewing.
- POWER React App (2) is included into a University website. Code is to be hosted by the Institutions. The REACT App (2) sends requests to the POWER middleware.
- POWER middleware (3) is deployed on an Institution server reachable by the one that hosts the Institution's website. It authenticates the requests sent by the React App and forwards them to the POWER platform's (1) API. Incoming requests the middleware should be restricted to the IP address of the university server, where the React app is located.
- The POWER platform stores and exposes placement opportunity data to the middleware and through it, to the REACT App, that is shown on the University websites.
Go to the POWER platform and check the 'How to start using the POWER platform' chapter on the help page if you haven't already done so.
This POWER middleware solution is based on Slim PHP. According to the official documentation, system requirements are:
- Web server with URL rewriting (Apache or Nginx recommended)
- PHP 7.4 or newer
Note: You do not have to perform the steps detailed in the official installation guide.
In order to leverage this repository:
- Git must be installed on the server.
- Composer 2 must be present on your server. See the official composer documentation on how to install it.
-
Create a domain / subdomain for the middleware on the hosting server.
-
Create a site in your webserver (Apache or Nginx) on the hosting server, that has PHP 7.4+ and URL rewriting installed and is accessible by the website that contains the POWER React app.
-
Enter the root directory of the site and clone the repository there:
git clone git@github.com:EuropeanUniversityFoundation/power-middleware-slim.git
-
Run
composer install
to install the dependencies of this repository. -
Set the document root (the home directory served by the site) to the
./public
directory. -
Duplicate the
power_settings.example.php
file with the namepower_settings.php
and edit it's content. -
Insert the API key you received from us, between the quotes:
<?php
$power_settings = [
'api_key' => '[Enter your API key here]',
'base_url' => 'https://power.uni-foundation.eu',
];
If you don't have an API key, check the 'How to start using the POWER platform' on the POWER platform site and follow the instructions there.
To test if the deployment was succesful, send a GET request to http(s)://[domain you installed to]/power-middleware/rest/public-pos
, where you should see placement opportunity data in JSON format.
Once you're done with this deployment, you can start to deploy and setting up the POWER React Application