Compare commits
9
Commits
a6b9ee5b09
...
v1.0.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
eaf197f86e | ||
|
|
7b98fab2c8 | ||
|
|
d7ab571bbe | ||
|
|
87fcd522c4 | ||
|
|
5884d840e7 | ||
|
|
a631b8cd1e | ||
|
|
8bc5200f77 | ||
|
|
8878dbb454 | ||
|
|
ecf275dedd |
@@ -34,6 +34,8 @@ jobs:
|
||||
|
||||
- name: Build and Push
|
||||
uses: https://github.com/docker/build-push-action@v5
|
||||
env:
|
||||
SQLX_OFFLINE: true
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
|
||||
@@ -18,6 +18,7 @@ repos:
|
||||
pass_filenames: false
|
||||
stages: [pre-commit]
|
||||
|
||||
# ─────────────── PRE-PUSH (heavy checks) ───────────────
|
||||
- id: sqlx-prepare-check
|
||||
name: sqlx prepare check
|
||||
entry: cargo sqlx prepare --check
|
||||
@@ -25,7 +26,6 @@ repos:
|
||||
pass_filenames: false
|
||||
stages: [pre-push]
|
||||
|
||||
# ─────────────── PRE-PUSH (heavy checks) ───────────────
|
||||
- id: test
|
||||
name: cargo test
|
||||
entry: bash -c 'SQLX_OFFLINE=true cargo test --all'
|
||||
@@ -42,7 +42,7 @@ repos:
|
||||
|
||||
- id: audit
|
||||
name: cargo audit
|
||||
entry: cargo audit
|
||||
entry: bash -c 'cargo audit || echo "cargo audit failed (non-blocking)"'
|
||||
language: system
|
||||
pass_filenames: false
|
||||
stages: [pre-push]
|
||||
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "\n INSERT INTO auth.api_key (key_hash, name, created_by, scopes)\n VALUES ($1, $2, $3, $4)\n ",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Text",
|
||||
"Text",
|
||||
"Uuid",
|
||||
"TextArray"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "14b38b0f3fca61893dc6e036dc68f643a724b729f73f8308ae0b3a70d87dc5de"
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "\n INSERT INTO auth.app_user (id)\n VALUES ($1)\n ON CONFLICT (id) DO NOTHING\n ",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Uuid"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "70117c16fc3efeebbcb40838d13dd427bf246f4eabd3e335077f47a7aa7882e4"
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "\n UPDATE auth.api_key\n SET last_used_at = now()\n WHERE id = $1\n ",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Uuid"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "ab03067777ea2a8f12c3dec5cf99caf4ad700008d892a33c25408c34bebab83c"
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "\n SELECT u.id AS user_id, ak.id as key_id\n FROM auth.api_key ak\n JOIN auth.app_user u ON u.id = ak.created_by\n WHERE ak.key_hash = $1\n AND ak.revoked_at IS NULL\n ",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "user_id",
|
||||
"type_info": "Uuid"
|
||||
},
|
||||
{
|
||||
"ordinal": 1,
|
||||
"name": "key_id",
|
||||
"type_info": "Uuid"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Text"
|
||||
]
|
||||
},
|
||||
"nullable": [
|
||||
false,
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "c0816078de6c25d441752500b9307900ff3d6c7781ebd9c0d8b47031539d8bdf"
|
||||
}
|
||||
@@ -17,6 +17,7 @@ RUN rm -rf src
|
||||
|
||||
# Build actual app
|
||||
COPY src ./src
|
||||
COPY .sqlx ./.sqlx
|
||||
RUN cargo build --release
|
||||
|
||||
# ── Runtime Stage ─────────────────────────────────────────────────────────────
|
||||
|
||||
+7
-1
@@ -55,7 +55,13 @@ async fn main() {
|
||||
|
||||
let cors = CorsLayer::new()
|
||||
.allow_origin(cors_origin.parse::<HeaderValue>().unwrap())
|
||||
.allow_methods([Method::GET, Method::POST, Method::PUT, Method::DELETE])
|
||||
.allow_methods([
|
||||
Method::GET,
|
||||
Method::POST,
|
||||
Method::PUT,
|
||||
Method::DELETE,
|
||||
Method::OPTIONS,
|
||||
])
|
||||
.allow_headers([
|
||||
header::CONTENT_TYPE,
|
||||
header::AUTHORIZATION,
|
||||
|
||||
@@ -27,7 +27,7 @@ pub fn protected_router() -> Router<AppState> {
|
||||
.route(
|
||||
"/keys/generate",
|
||||
post(apikey::create_api_key).route_layer(middleware::from_fn(|req, next| {
|
||||
require_roles(req, next, None, None)
|
||||
require_roles(req, next, None, Some("admin"))
|
||||
})),
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user