Skip to content

Commit

Permalink
Merge pull request #56 from Newman101/feature/api-docs
Browse files Browse the repository at this point in the history
README.md: API
  • Loading branch information
jremes-foss authored Nov 9, 2020
2 parents 6c5d9de + 7494b5e commit 24980ce
Show file tree
Hide file tree
Showing 7 changed files with 1,300 additions and 652 deletions.
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,29 @@ Alternatively, you can also check which services are up:
docker-compose ps
```

## API
There is an internal API available. This API is used for various purposes, including listing challenges, categories, and getting scoreboard on the command line.

### Get Categories and Challenges
BeeCTF API allows you to fetch all categories and challenges in JSON format. Syntax as follows:

```bash
curl -X GET http://HOST/api/categories?api_token=API_TOKEN -H "Accept: application/json" -H "Content-Type: application/json"
```

```bash
curl -X GET http://HOST/api/challenges?api_token=API_TOKEN -H "Accept: application/json" -H "Content-Type: application/json"
```

### Get Scoreboard
You can fetch the scoreboard via BeeCTF API. Example with cURL:

```bash
curl -X GET http://HOST/api/scoreboard?api_token=API_TOKEN -H "Accept: application/json" -H "Content-Type: application/json"
```

This command returns the scoreboard in JSON format.

## Pull Requests
Feel free to send any bug fixes, new features, etc. via pull requests. Please note that BeeCTF is still heavily work in progress so there are a lot of issues to fix and all contributions are welcome. Before submitting unit tests, please make sure all unit tests pass and the code is following the standards established in contribution guide.

Expand Down
16 changes: 9 additions & 7 deletions app/Http/Middleware/TrustProxies.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ class TrustProxies extends Middleware
*
* @var array
*/
protected $headers = [
Request::HEADER_FORWARDED => 'FORWARDED',
Request::HEADER_X_FORWARDED_FOR => 'X_FORWARDED_FOR',
Request::HEADER_X_FORWARDED_HOST => 'X_FORWARDED_HOST',
Request::HEADER_X_FORWARDED_PORT => 'X_FORWARDED_PORT',
Request::HEADER_X_FORWARDED_PROTO => 'X_FORWARDED_PROTO',
];
// protected $headers = [
// Request::HEADER_FORWARDED => 'FORWARDED',
// Request::HEADER_X_FORWARDED_FOR => 'X_FORWARDED_FOR',
// Request::HEADER_X_FORWARDED_HOST => 'X_FORWARDED_HOST',
// Request::HEADER_X_FORWARDED_PORT => 'X_FORWARDED_PORT',
// Request::HEADER_X_FORWARDED_PROTO => 'X_FORWARDED_PROTO',
// ];

protected $headers = Request::HEADER_X_FORWARDED_ALL;
}
Loading

0 comments on commit 24980ce

Please sign in to comment.