Skip to content

Commit

Permalink
Merge pull request #124 from nightly-labs/grafana
Browse files Browse the repository at this point in the history
Grafana
  • Loading branch information
NorbertBodziony authored Mar 11, 2024
2 parents 52c2503 + 56e9f53 commit 7de02e3
Show file tree
Hide file tree
Showing 14 changed files with 260 additions and 70 deletions.
72 changes: 71 additions & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,4 +1,74 @@
ENV=DEV # PROD or DEV
ONLY_RELAY_SERVICE=True # TRUE - This will start only nightly relay service without cloud service
NONCE=VERY_SECRET_NONCE
JWT_SECRET=VERY_SECRET_SECRET
# Generated so it can work with grafana
# ssh-keygen -t rsa -b 4096 -m PEM -f grafana.key -N ""
# openssl rsa -in grafana.key -pubout -outform PEM -out grafana.key.pub
# TEST KEY DO NO USE IN PRODUCTION
JWT_SECRET="-----BEGIN RSA PRIVATE KEY-----
MIIJKQIBAAKCAgEAzlUYIpqSUAyLJaf8ZUef06YBh5DcmaTrwGcVwC57VtywY7bH
XQUtGooULQjiYgnyOPxHDt2W+gQW1axiMxOQew0MF0kXYQhg0+WA1dcWOsxCDpyL
c4z+E7EmdV7MTuvsDR2TLhZ6DFmVbN4ca64Wvftz//3Ptc/I1/VpfGsHWb0Vpmph
kbE9vWGHzzJVp/Lvtk7ybcpfxiiNWEi7unr7/TIEsqy93lCRfpLKIvO06ITH1GZz
7+VPL/8q8lrH5kSwxqo5szq1mEa0pNN6hTpocz00x5oBfL9K/TNLQNgdb5uOOfjQ
9pYtZ49UDyMLs5lCsZ6ue+SIbWrJXDEPMIEgLzx9nnvytL9wbiwo5GQdIaDAZXMw
VVdKQGyqx+UhaHmrb1u0RVRcFzO/QPWzNCWvoxJGfg9dVTxfjaa1HzQ0irPs86zC
QUnt0OyTuq0SmUgTCNXLSQaN8MigN++zwT4cIRDB0WMgmu8sxtnmA3Zq+2GYT97j
mbdVMB34DVbXI4UigD3UieVe4rO95cEssoUTAFG0pthv64BRKIIRNch+eiBBjkGp
nWKRybzsmqnEqpMf9v7KQU9h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ssoUT
AFG0pthv64BRKIIRNch+eiBBjkGpnWKRybzsmqnEqpMf9v7KQU9hmpBJDbi6KA6w
3fg3KSroJZwosbAwdBuylCfQgq1jZ6UfR/ss9kYGhaWbCB3ARmY9XHFc+OZuFW0p
ohgfBfs9RDMDVkTa4tzBAGsCAwEAAQ==
-----END PUBLIC KEY-----
"
10 changes: 8 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ctrlc = "3.4.2"
serde = { version = "1.0.197", features = ["derive"] }
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
once_cell = "1.19.0"
garde = { version = "0.18.0", features = ["derive", "email", "regex"]}
garde = { version = "0.18.0", features = ["derive", "email", "regex"] }
anyhow = "1.0.79"
serde_json = "1.0.113"
strum = { version = "0.26.1", features = ["derive"] }
Expand All @@ -32,5 +32,11 @@ tokio = { version = "1.35.1", features = ["full"] }
async-trait = "0.1.77"

# If you're updating sqlx, make sure that chrono version below is the same as the one in sqlx
sqlx = { version = "0.7.3", features = [ "runtime-tokio", "tls-rustls", "macros", "postgres", "chrono"] }
sqlx = { version = "0.7.3", features = [
"runtime-tokio",
"tls-rustls",
"macros",
"postgres",
"chrono",
] }
chrono = { version = "0.4.22", features = ["serde"] }
1 change: 1 addition & 0 deletions grafana/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
grafana-data
19 changes: 19 additions & 0 deletions grafana/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
version: '3.1'

services:
grafana:
image: grafana/grafana:latest
# container_name: grafana
# environment:
# - GF_SECURITY_ADMIN_PASSWORD=secret # Change 'secret' to a strong password
# - GF_USERS_ALLOW_SIGN_UP=false
volumes:
- ./grafana-data:/var/lib/grafana # Persists Grafana data
- ./grafana.ini:/etc/grafana/grafana.ini # Optional: Custom Grafana configuration
- ../jwt_keys/grafana.key.pub:/etc/grafana/public-key.pem # Optional: Custom Grafana configuration
ports:
- '3000:3000'
restart: unless-stopped

volumes:
grafana-data:
8 changes: 8 additions & 0 deletions grafana/grafana.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[auth.jwt]
enabled = true
header_name = X-JWT-Assertion
email_claim = sub
username_claim = sub
auto_sign_up = true
key_file = /etc/grafana/public-key.pem
url_login = true
6 changes: 6 additions & 0 deletions grafana/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Setup

1. Use openresty
2. Use grafana without auth
3. Generate JWT on backed
4. Validate JWT in openresty/nginx
51 changes: 51 additions & 0 deletions jwt_keys/grafana.key
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
-----BEGIN RSA PRIVATE KEY-----
MIIJKQIBAAKCAgEAzlUYIpqSUAyLJaf8ZUef06YBh5DcmaTrwGcVwC57VtywY7bH
XQUtGooULQjiYgnyOPxHDt2W+gQW1axiMxOQew0MF0kXYQhg0+WA1dcWOsxCDpyL
c4z+E7EmdV7MTuvsDR2TLhZ6DFmVbN4ca64Wvftz//3Ptc/I1/VpfGsHWb0Vpmph
kbE9vWGHzzJVp/Lvtk7ybcpfxiiNWEi7unr7/TIEsqy93lCRfpLKIvO06ITH1GZz
7+VPL/8q8lrH5kSwxqo5szq1mEa0pNN6hTpocz00x5oBfL9K/TNLQNgdb5uOOfjQ
9pYtZ49UDyMLs5lCsZ6ue+SIbWrJXDEPMIEgLzx9nnvytL9wbiwo5GQdIaDAZXMw
VVdKQGyqx+UhaHmrb1u0RVRcFzO/QPWzNCWvoxJGfg9dVTxfjaa1HzQ0irPs86zC
QUnt0OyTuq0SmUgTCNXLSQaN8MigN++zwT4cIRDB0WMgmu8sxtnmA3Zq+2GYT97j
mbdVMB34DVbXI4UigD3UieVe4rO95cEssoUTAFG0pthv64BRKIIRNch+eiBBjkGp
nWKRybzsmqnEqpMf9v7KQU9hmpBJDbi6KA6w3fg3KSroJZwosbAwdBuylCfQgq1j
Z6UfR/ss9kYGhaWbCB3ARmY9XHFc+OZuFW0pohgfBfs9R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/6jIfEXbCemkWQ5Drs
CF6jk7gUREbNiTpfWUYSa4DcsyB5phvn2MTM/rsunWtKBrRl7FwDPZcIHrNnsp1U
w/OPG9nl9ScULy34hwksYShrFZPGeWM8dg+zB1LpwgzsirQiXqmu5FDUrzmCqLM6
8GYuZHYXowAU0LDUtn/z8Mqv05HR/NwTZxDlxyJMIdVdoUYyWtYUAHb5p839N1Qx
tj4b9QGK2SBDcOQwq8eCnK/DUjIBUTL+4DNSDeQCr8gc82SwkoZGBCwIWQH+ZwDz
noL/o/3a5OnNQI0eB7/0g6ElR8BmkeZy1sZXaxZ3caatctEUuUgVFYuVkf9m
-----END RSA PRIVATE KEY-----
14 changes: 14 additions & 0 deletions jwt_keys/grafana.key.pub
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
-----BEGIN PUBLIC KEY-----
MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAzlUYIpqSUAyLJaf8ZUef
06YBh5DcmaTrwGcVwC57VtywY7bHXQUtGooULQjiYgnyOPxHDt2W+gQW1axiMxOQ
ew0MF0kXYQhg0+WA1dcWOsxCDpyLc4z+E7EmdV7MTuvsDR2TLhZ6DFmVbN4ca64W
vftz//3Ptc/I1/VpfGsHWb0VpmphkbE9vWGHzzJVp/Lvtk7ybcpfxiiNWEi7unr7
/TIEsqy93lCRfpLKIvO06ITH1GZz7+VPL/8q8lrH5kSwxqo5szq1mEa0pNN6hTpo
cz00x5oBfL9K/TNLQNgdb5uOOfjQ9pYtZ49UDyMLs5lCsZ6ue+SIbWrJXDEPMIEg
Lzx9nnvytL9wbiwo5GQdIaDAZXMwVVdKQGyqx+UhaHmrb1u0RVRcFzO/QPWzNCWv
oxJGfg9dVTxfjaa1HzQ0irPs86zCQUnt0OyTuq0SmUgTCNXLSQaN8MigN++zwT4c
IRDB0WMgmu8sxtnmA3Zq+2GYT97jmbdVMB34DVbXI4UigD3UieVe4rO95cEssoUT
AFG0pthv64BRKIIRNch+eiBBjkGpnWKRybzsmqnEqpMf9v7KQU9hmpBJDbi6KA6w
3fg3KSroJZwosbAwdBuylCfQgq1jZ6UfR/ss9kYGhaWbCB3ARmY9XHFc+OZuFW0p
ohgfBfs9RDMDVkTa4tzBAGsCAwEAAQ==
-----END PUBLIC KEY-----
17 changes: 17 additions & 0 deletions jwt_keys/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import jwt
import time
import webbrowser

private_key = open('./grafana.key', 'r').read()

payload = {
"sub": "yolo2",
"iat": int(time.time())
}

token = jwt.encode(payload, private_key, algorithm='RS256')

base_url = 'http://localhost:3000'
url_with_token = f'{base_url}?auth_token={token}'
print(url_with_token)
# webbrowser.open_new_tab(url_with_token)
2 changes: 1 addition & 1 deletion server/bindings/CloudApiErrors.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.

export type CloudApiErrors = "TeamDoesNotExist" | "UserDoesNotExist" | "CloudFeatureDisabled" | "InsufficientPermissions" | "TeamHasNoRegisteredApps" | "DatabaseError" | "MaximumUsersPerTeamReached" | "UserAlreadyBelongsToTheTeam" | "IncorrectPassword" | "AccessTokenFailure" | "RefreshTokenFailure" | "AppAlreadyExists" | "MaximumAppsPerTeamReached" | "TeamAlreadyExists" | "PersonalTeamAlreadyExists" | "EmailAlreadyExists" | "InternalServerError" | "UserDoesNotBelongsToTheTeam";
export type CloudApiErrors = "TeamDoesNotExist" | "UserDoesNotExist" | "CloudFeatureDisabled" | "InsufficientPermissions" | "TeamHasNoRegisteredApps" | "DatabaseError" | "MaximumUsersPerTeamReached" | "UserAlreadyBelongsToTheTeam" | "IncorrectPassword" | "AccessTokenFailure" | "RefreshTokenFailure" | "AppAlreadyExists" | "MaximumAppsPerTeamReached" | "TeamAlreadyExists" | "PersonalTeamAlreadyExists" | "EmailAlreadyExists" | "InternalServerError" | "UserDoesNotBelongsToTheTeam" | "InvalidName";
4 changes: 2 additions & 2 deletions server/src/auth/auth_middleware.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::{auth_token_type::AuthTokenType, AuthToken};
use crate::env::JWT_SECRET;
use crate::env::JWT_PUBLIC_KEY;
use axum::{
extract::{ConnectInfo, Request},
http::{HeaderMap, StatusCode},
Expand Down Expand Up @@ -27,7 +27,7 @@ pub async fn access_auth_middleware(
Some(auth_header) => {
let token = auth_header.replace("Bearer ", "");
// Decode and validate the token
let decoded = match AuthToken::decode(&token, JWT_SECRET(), ip) {
let decoded = match AuthToken::decode(&token, JWT_PUBLIC_KEY(), ip) {
Ok(decoded) => decoded,
Err(e) => return Err((StatusCode::UNAUTHORIZED, e.to_string())),
};
Expand Down
Loading

0 comments on commit 7de02e3

Please sign in to comment.