Method | URL | Headers | Data | Description |
---|---|---|---|---|
GET | /api/auth | Access-Token | / | Infos über eigenen Account |
POST | /api/auth | username, password | Login | |
DELETE | /api/auth | Access-Token | / | Logout |
GET | /api/roles | Access-Token | / | Get all roles |
GET | /api/roles/{name:string} | Access-Token | / | Get a role |
POST | /api/roles | Access-Token | name, description | Admin: create role |
PUT | /api/roles/{name:string} | Access-Token | description | Admin: modify role (description) |
DELETE | /api/roles/{name:string} | Access-Token | / | Admin: delete role |
GET | /api/users | Access-Token | / | Admin: Get all accounts |
GET | /api/users/{uuid:string} | Access-Token | / | Admin: Get a account |
POST | /api/users | username, email, password | Register a new account | |
POST | /api/users | Access-Token | username, email, password, role | Admin: Create a new account |
PUT | /api/users/{uuid:string} | Access-Token | username (and/or) email (and/or) password | Admin: update user (by UUID) |
PUT | /api/users/me | Access-Token | username (and/or) email (and/or) password | update your account |
DELETE | /api/users/{uuid:string} | Access-Token | / | Admin: delete user (by UUID) |
DELETE | /api/users/me | Access-Token | / | delete your account |
GET | /api/categories | Access-Token | / | Get all categories |
GET | /api/categories/{name:string} | Access-Token | / | Get a category |
POST | /api/categories | Access-Token | name, description | Admin: create category |
PUT | /api/categories/{name:string} | Access-Token | description | Admin: modify category (description) |
DELETE | /api/categories/{name:string} | Access-Token | / | Admin: delete category |
GET | /api/urls/ | Access-Token | / | Get all urls |
GET | /api/urls/{id:int} | Access-Token | / | Get a url |
POST | /api/urls | Access-Token | url, description, challenge | Admin: create url |
PUT | /api/urls/{id:int} | Access-Token | url, description, challenge | Admin: modify url |
DELETE | /api/urls/{id:int} | Access-Token | / | Admin: delete url |
GET | /api/challenges | Access-Token | / | Get all challenges (except special and not published challenges) |
GET | /api/challenges | Access-Token | / | Admin: Get all challenges |
GET | /api/challenges/{id:int} | Access-Token | / | Get challenge (except special and not published challenges) |
GET | /api/challenges/{id:int} | Access-Token | / | Admin: Get challenge |
POST | /api/challenges | Access-Token | name, description, category, flag, points | Admin: create challenge |
PUT | /api/challenges/{id:int} | Access-Token | ytChallengeId (and/or) ytSolutionId (and/or) description (and/or) points | Admin: update challenge (YouTube video id's and/or description) |
POST | /api/solve | Access-Token | flag | Solve Special Challenge |
PUT | /api/solve/{id:int} | Access-Token | flag | Solve Challenge |
PUT | /api/rate/{challenge_id:int} | Access-Token | thumbUp(boolean) | Rate a challenge |
GET | /api/leaderboard/me | Access-Token | Get my rank | |
GET | /api/leaderboard | Access-Token | Get leaderboard |
- Role:
name
,description
- Account (user):
publicId
,username
,email
,created
,lastLogin
,role
(name
,description
),solved
(challenge
(id
,name
,category
),timestamp
) - Category:
name
,description
- URL:
id
,url
,description
,challenge
(id
,name
,category
(name
,description
)) - Challenge:
id
,name
,description
,points
,category
(name
,description
),ytChallengeId
,ytSolutionId
,urls
[(id
,url
,description
), ...],solveCount
,ratings
(thumbUp
,thumbDown
)
Table | Attribute | Datatype (Length) (+ Description) | Settings |
---|---|---|---|
users | id | Integer(11) | primary key, auto increment |
publicId | Varchar(36) (for uuid4) | unique | |
username | Varchar(80) | unique | |
Varchar(100) | unique | ||
password | Blob(512) (sha512 Hash) | ||
lastLogin | TimeStamp | ||
created | TimeStamp | ||
role | Integer(11) | foreign key -> role.id | |
roles | id | Integer(11) | primary key, auto increment |
name | Varchar(80) | ||
description | Varchar(100) | ||
tokens | id | Integer(11) | primary key, auto increment |
user | Integer(11) | foreign key -> user.id | |
token | Varchar(128) | unique | |
created | TimeStamp | ||
expires | TimeStamp | ||
broken | Integer(1) (boolean) | ||
challenge | id | Integer(11) | primary key, auto increment |
flag | Varchar(80) | unique | |
points | Integer(11) | ||
name | Varchar(80) | unique | |
description | Varchar(512) | ||
ytChallengeId | Varchar(10) | ||
ytSolutionId | Varchar(10) | ||
category | Varchar(80) | ||
created | DateTime | ||
publication | DateTime | ||
ratings | id | Integer(11) | |
user | Integer(11) | foreign key -> user.id | |
challenge | Integer(11) | foreign key -> challenge.id | |
thumbUp | Boolean | ||
created | DateTime | ||
url | id | Integer(11) | primary key, auto increment |
description | Varchar(100) | ||
url | Varchar(100) | unique | |
challenge | Integer(11) | foreign key -> challenge.id | |
solved | id | Integer(11) | primary key, auto increment |
challenge | Integer(11) | foreign key -> challenge.id | |
user | Integer(11) | foreign key -> user.id | |
timestamp | TimeStamp |
- Install Docker and docker-compose
- Build Docker Image
git clone ssh://[email protected]:322/challengeInterface/backend.git
docker build -t backend .
- Define your container in the file
docker-compose.yml
:
version: '3'
services:
db:
image: mysql:5.7
container_name: root_db_1
restart: always
ports:
- "9999:3306"
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: hc
volumes:
- "/srv/mysql:/var/lib/mysql"
backend:
image: backend
container_name: root_backend_1
restart: always
ports:
- "8080:80"
environment:
MYSQL_PASSWORD: root
- Add database hc (in this example automatically)
- Change database collection from
latin1_swedish_ci
toutf8mb4_unicode_ci
- Execute following sql:
INSERT INTO `category` (`id`, `name`, `description`) VALUES
(1, 'hc', 'Hacking Challenges'),
(2, 'cc', 'Coding Challenges'),
(3, 'special', 'Special Challenges');
INSERT INTO `role` (`id`, `name`, `description`) VALUES
(1, 'admin', 'Admin'),
(2, 'user', 'User');
- Use docker-compose:
# Start all containers
docker-compose up -d
# Stop all containers
docker-compose stop
# Stop and remove all containers
docker-compose down
# Start a specific container
docker-compose up -d <container>
# Stop a specific container
docker-compose stop <container>
# Stop and remove a specific container
docker-compose rm -fs <container>
# Show logs
docker-compose logs [container]
# Show status
docker-compose ps [container]