Skip to content

Latest commit

 

History

History

Unprotected Server Example

The unprotected example is the base reference to build the Approov protected servers. This a very basic Hello World API server.

TOC - Table of Contents

Why?

To be the starting building block for the Approov protected servers, that will show you how to lock down your API server to your mobile app. Please read the brief summary in the Approov Overview at the root of this repo or visit our website for more details.

TOC

How it works?

The PHP Laravel API server is very simple and is defined in the project located at src/unprotected-server/hello.

The server only replies to the endpoint / with the message:

{"message": "Hello, World!"}

TOC

Requirements

To run this example you will need to have at least PHP 7.2.5 installed. If you don't have then please follow the official installation instructions from here to download and install it.

TOC

Try It

First, you need to create the .env file. From the src/unprotected-server/hello folder execute:

cp .env.example .env

Next, you need to install the dependencies. From the src/unprotected-server/hello folder execute:

composer install

Now, you can run this example from the src/unprotected-server/hello folder with:

php artisan serve --port 8002

NOTE: If running the server inside a docker container add --host 0.0.0.0., otherwise the Laravel server will not answer requests from outside the container, like the ones you may want to do from cURL or Postman to test the API.

Finally, you can test that it works with:

curl -iX GET 'http://localhost:8002'

The response will be:

HTTP/1.1 200 OK
Host: localhost:8002
Date: Thu, 01 Oct 2020 13:53:58 GMT
Connection: close
X-Powered-By: PHP/7.2.18
Cache-Control: no-cache, private
Date: Thu, 01 Oct 2020 13:53:58 GMT
Content-Type: application/json

{"message":"Hello, World!"}

TOC

Issues

If you find any issue while following our instructions then just report it here, with the steps to reproduce it, and we will sort it out and/or guide you to the correct path.

TOC

Useful Links

If you wish to explore the Approov solution in more depth, then why not try one of the following links as a jumping off point:

TOC