Skip to content

Commit e1b5a85

Browse files
authored
Merge pull request #1 from CactuseSecurity/devel-api
Devel api
2 parents 35ac734 + b3d13f5 commit e1b5a85

File tree

7 files changed

+100
-0
lines changed

7 files changed

+100
-0
lines changed

design/readme.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
2+
# Designziele
3+
4+
- Einfache Entwicklung im (erweiterbaren) Team
5+
- Open Source
6+
- Clean Code (Doku, Tests, coding best practices ...)
7+
- Klare Modularisierung (mittels API), keine Logik im Client
8+
- Sicherer Code, mandantenfähige Nutzung, RBAC
9+
- Moderne & "zeitlose" GUI
10+
- Wartbarkeit (einfaches Einspielen, Bereitstellen von Updates, updater?)
11+
12+
# Design-, Methoden- und Toolentscheidungen
13+
14+
- GitHub.com
15+
- Rapid Prototyping (Trial & Error, MuP)
16+
- PostgreSQL
17+
- GraphQL statt REST API
18+
- Client: Apollo (https://www.apollographql.com/)
19+
- Verwendung von hasura
20+
21+
# Funktionale Anforderungen (High-Level)
22+
23+
- Kostengünstige Alternative zu den Kernfunktionalitäten der Konkurrenz (Tufin, Algosec, Skybox)
24+
- Abdecken der regulatorischen Richtlinien (Dokumentation Config-Änderungen, Rezertifizierung Config)
25+
- "CMDB Netzwerk"
26+
- kritische Funktionen nicht im Kernprodukt (Config-Änderungen)
27+
- Bereitstellung offener Schnittstellen zur Automatisierung

inventory/group_vars/backends

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ api_user: "{{ iso_dbadmin_name }}"
66
api_user_password: "{{ dbadmin_pwd }}"
77
api_user_email: "{{ api_user }}@localhost"
88
api_hasura_admin_secret: "st8chelt1er"
9+
api_hasura_jwt_secret: "todo: to be filled, migrating from auth0 to local auth with django-graphql-jwt"
910
api_hostname: "127.0.0.1"
1011
api_port: 8080
1112
API_SECRET_KEY: '3s)3o5_@2d!t21nammq38hnux9cfz5#9o0&nb4y8yn5xvqdhh^'

roles/api/doc/api_calls.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
Method: POST
2+
URL: https://demo.itsecorg.de/api/v1/graphql
3+
4+
Header:
5+
x-hasura-admin-secret --> st8chelt1er
6+
content-type --> application/json
7+
x-hasura-role-id --> ?
8+
9+
--------------------
110

211
query listRulesOfAllDevicesResolved {
312
device {
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
https://hasura.io/blog/add-authentication-and-authorization-to-next-js-8-serverless-apps-using-jwt-and-graphql/
2+
3+
choosing between auth modes JWT & webhook: https://hasura.io/learn/graphql/hasura-auth-slack/choosing-jwt-mode/
4+
5+
https://hasura.io/learn/graphql/hasura-auth-slack/choosing-jwt-mode/1-choosing-auth-mode/
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,57 @@
11
source: https://www.howtographql.com/graphql-python/4-authentication/
2+
https://django-graphql-jwt.domake.io/en/latest/settings.html
3+
4+
only for ubuntu upgraded to 20.04:
5+
sudo apt purge php7.3-common
6+
sudo a2dismod php7.3
7+
8+
sudo apt install python3-pip python3-venv
9+
pip3 install django-graphql-jwt wheel
10+
11+
git clone https://github.com/howtographql/graphql-python.git
12+
cd graphql-python
13+
python3 -m venv venv
14+
source venv/bin/activate
15+
16+
pip3 install -r requirements.txt
17+
python3 hackernews/manage.py migrate
18+
python3 hackernews/manage.py runserver
19+
20+
browse to http://localhost:8000/graphql/
21+
22+
23+
# mutation to create user:
24+
mutation {
25+
createUser(username:"tim", email:"[email protected]", password:"abc") {
26+
user {
27+
id
28+
username
29+
email
30+
}
31+
}
32+
}
33+
34+
# mutation to login in user with password and to obtain token:
35+
mutation {
36+
tokenAuth(username: "tim", password: "abc") {
37+
token
38+
}
39+
}
40+
41+
# mutation to verify token validity:
42+
mutation {
43+
verifyToken(token: "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VybmFtZSI6InRpbSIsImV4cCI6MTU4ODQ5MjIzNywib3JpZ0lhdCI6MTU4ODQ5MTkzN30.r1JNmgef6OQc4lMDQtoGiWI2JEWJcdBEvKVi-ptePEU") {
44+
payload
45+
}
46+
}
47+
48+
# mutation to refresh token:
49+
mutation {
50+
refreshToken(token: "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VybmFtZSI6InRpbSIsImV4cCI6MTU4ODQ5MjIzNywib3JpZ0lhdCI6MTU4ODQ5MTkzN30.r1JNmgef6OQc4lMDQtoGiWI2JEWJcdBEvKVi-ptePEU") {
51+
payload
52+
}
53+
}
254

355
https://blog.apollographql.com/authorization-in-graphql-452b1c402a9
56+
57+

roles/api/doc/tools.MD

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
- graphql query tool insomnia
2+
- ubuntu: sudo snap install insomnia oder:
3+
- https://insomnia.rest/download/core/?&ref=

roles/api/templates/docker-run.sh.j2

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ docker run -d --net=host -p {{ api_listener_ip }}:8080:8080 \
44
-e HASURA_GRAPHQL_DATABASE_URL=postgres://{{ api_user }}:{{ api_user_password }}@{{ isodb_host }}:{{ iso_db_port }}/{{ iso_db_name }} \
55
-e HASURA_GRAPHQL_ENABLE_CONSOLE=true \
66
-e HASURA_GRAPHQL_ADMIN_SECRET={{ api_hasura_admin_secret }} \
7+
-e HASURA_GRAPHQL_JWT_SECRET={{ api_hasura_jwt_secret }} \
78
hasura/graphql-engine:v1.0.0

0 commit comments

Comments
 (0)