Compare commits

..
2 Commits
Author SHA1 Message Date
Ruslan Bakiev ccdf536763 Provision default client team context
Build and deploy Docker image / build (push) Successful in 2m58s
2026-08-20 18:47:37 +07:00
Ruslan Bakiev e74ab26d6b ci: deploy through Earth Dokploy
Build and deploy Docker image / build (push) Successful in 2m8s
2026-08-19 18:24:49 +07:00
2 changed files with 33 additions and 21 deletions
+14 -16
View File
@@ -1,6 +1,7 @@
name: Build and deploy Docker image name: Build and deploy Docker image
on: on:
workflow_dispatch:
push: push:
branches: [main] branches: [main]
@@ -12,24 +13,21 @@ jobs:
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Isolate Docker auth - name: Build and publish
run: |
mkdir -p "$RUNNER_TEMP/docker-config"
echo "DOCKER_CONFIG=$RUNNER_TEMP/docker-config" >> "$GITHUB_ENV"
- name: Login to Gitea Registry
uses: docker/login-action@v3
with:
registry: gitea.dsrptlab.com
username: ${{ gitea.actor }}
password: ${{ secrets.REGISTRY_TOKEN }}
- name: Build and push
run: | run: |
set -euo pipefail
docker build -t "$IMAGE:latest" -t "$IMAGE:${{ gitea.sha }}" . docker build -t "$IMAGE:latest" -t "$IMAGE:${{ gitea.sha }}" .
docker push "$IMAGE:latest" docker push "$IMAGE:latest"
docker push "$IMAGE:${{ gitea.sha }}" docker push "$IMAGE:${{ gitea.sha }}"
docker image rm -f "$IMAGE:latest" "$IMAGE:${{ gitea.sha }}"
- name: Deploy to Dokploy - name: Remove local image tags
run: curl -fsS -X POST "https://ind.dsrptlab.com/api/deploy/2Y2RjGRTm4HIkcO2UmyHL" run: docker image rm -f "$IMAGE:latest" "$IMAGE:${{ gitea.sha }}"
- name: Deploy in Dokploy
env:
DOKPLOY_DEPLOY_WEBHOOK: ${{ secrets.DOKPLOY_DEPLOY_WEBHOOK }}
run: |
set -euo pipefail
test -n "$DOKPLOY_DEPLOY_WEBHOOK"
curl -fsS -X POST "$DOKPLOY_DEPLOY_WEBHOOK"
+19 -5
View File
@@ -50,6 +50,12 @@ function scopesFromPayload(payload: JWTPayload): string[] {
return []; return [];
} }
function clientScopes(payload: JWTPayload): string[] {
return [
...new Set([...scopesFromPayload(payload), "teams:user", "teams:member"]),
];
}
export async function publicContext(): Promise<AuthContext> { export async function publicContext(): Promise<AuthContext> {
return { scopes: [] }; return { scopes: [] };
} }
@@ -72,7 +78,7 @@ function teamClaims(payload: JWTPayload): Pick<
"teamUuid" | "teamName" | "teamType" | "logtoOrgId" "teamUuid" | "teamName" | "teamType" | "logtoOrgId"
> { > {
return { return {
teamUuid: claimString(payload, "team_uuid"), teamUuid: claimString(payload, "team_uuid") ?? payload.sub,
teamName: teamName:
claimString(payload, "team_name") ?? claimString(payload, "team_name") ??
claimString(payload, "organization_name") ?? claimString(payload, "organization_name") ??
@@ -97,10 +103,18 @@ function hasManagerClaim(payload: JWTPayload): boolean {
export async function userContext(req: FastifyRequest): Promise<AuthContext> { export async function userContext(req: FastifyRequest): Promise<AuthContext> {
const token = optionalBearerToken(req); const token = optionalBearerToken(req);
if (token === null) return { scopes: [] }; if (token === null) return { scopes: [] };
const { payload } = await jwtVerify(token, jwks, { issuer: LOGTO_ISSUER }); const { payload } = await jwtVerify(token, jwks, {
issuer: LOGTO_ISSUER,
audience: LOGTO_TEAMS_AUDIENCE,
});
if (!payload.sub) {
throw new GraphQLError("User subject is required", {
extensions: { code: "UNAUTHENTICATED" },
});
}
return { return {
userId: payload.sub, userId: payload.sub,
scopes: scopesFromPayload(payload), scopes: clientScopes(payload),
...teamClaims(payload), ...teamClaims(payload),
}; };
} }
@@ -132,8 +146,8 @@ export async function teamContext(req: FastifyRequest): Promise<AuthContext> {
audience: LOGTO_TEAMS_AUDIENCE, audience: LOGTO_TEAMS_AUDIENCE,
}); });
const claims = teamClaims(payload); const claims = teamClaims(payload);
const scopes = scopesFromPayload(payload); const scopes = clientScopes(payload);
if (!claims.teamUuid || !scopes.includes("teams:member")) if (!payload.sub || !claims.teamUuid)
throw new GraphQLError("Unauthorized", { throw new GraphQLError("Unauthorized", {
extensions: { code: "UNAUTHENTICATED" }, extensions: { code: "UNAUTHENTICATED" },
}); });