Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
40151d403b
|
|||
| d2992d2af6 | |||
|
|
7930f2ec99 | ||
|
|
ef7abd386e | ||
|
|
bdc0d9beb2 | ||
|
|
eb8ba0eb74 | ||
|
|
31afa58ace | ||
|
|
63dba60c44 | ||
| b6d71a3929 | |||
|
|
3ba6d61117 | ||
|
|
6ea4019d55 | ||
|
|
91c53e5968 | ||
|
|
684ac2a8c3 |
9
.github/workflows/ci-cd.yml
vendored
9
.github/workflows/ci-cd.yml
vendored
@@ -4,7 +4,7 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches: [main, master]
|
branches: [main, master]
|
||||||
paths:
|
paths:
|
||||||
- 'src/'
|
- 'src/**'
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [main, master]
|
branches: [main, master]
|
||||||
|
|
||||||
@@ -22,6 +22,9 @@ jobs:
|
|||||||
- name: Download dependencies
|
- name: Download dependencies
|
||||||
run: /usr/local/go/bin/go mod download
|
run: /usr/local/go/bin/go mod download
|
||||||
|
|
||||||
|
- name: Tidy modules
|
||||||
|
run: /usr/local/go/bin/go mod tidy
|
||||||
|
|
||||||
- name: Check formatting
|
- name: Check formatting
|
||||||
run: |
|
run: |
|
||||||
if [ "$(/usr/local/go/bin/gofmt -l $(find . -name '*.go' -not -path './vendor/*'))" ]; then
|
if [ "$(/usr/local/go/bin/gofmt -l $(find . -name '*.go' -not -path './vendor/*'))" ]; then
|
||||||
@@ -76,7 +79,7 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
docker buildx build \
|
docker buildx build \
|
||||||
--platform linux/amd64 \
|
--platform linux/amd64 \
|
||||||
--tag "git.yejayekhoob.com/db123/auth-proxy:${{ github.sha }}" \
|
--tag "git.yejayekhoob.com/yjkh/auth-proxy:${{ github.sha }}" \
|
||||||
--tag "git.yejayekhoob.com/db123/auth-proxy:latest" \
|
--tag "git.yejayekhoob.com/yjkh/auth-proxy:latest" \
|
||||||
--push \
|
--push \
|
||||||
.
|
.
|
||||||
|
|||||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,2 +1,3 @@
|
|||||||
*.exe
|
*.exe
|
||||||
*.env
|
*.env
|
||||||
|
*.db*
|
||||||
|
|||||||
5
LICENSE
Normal file
5
LICENSE
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
Copyright (c) 2026 db123. All Rights Reserved.
|
||||||
|
|
||||||
|
This software and associated documentation files (the "Software") are proprietary and confidential. No part of the Software may be reproduced, distributed, or transmitted in any form or by any means, including photocopying, recording, or other electronic or mechanical methods, without the prior written permission of the copyright holder.
|
||||||
|
|
||||||
|
For licensing inquiries, contact: erfan@db123.ir
|
||||||
25
src/auth.go
25
src/auth.go
@@ -243,8 +243,15 @@ func parseLogFilter(r *http.Request) (*logFilter, error) {
|
|||||||
Offset: 0,
|
Offset: 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
validActions := map[string]bool{
|
||||||
|
"add_temp": true, "delete_temp": true,
|
||||||
|
"add_perm": true, "delete_perm": true, "expire_temp": true,
|
||||||
|
}
|
||||||
|
|
||||||
if v := r.URL.Query().Get("action"); v != "" {
|
if v := r.URL.Query().Get("action"); v != "" {
|
||||||
f.Action = v
|
if validActions[v] {
|
||||||
|
f.Action = v
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if v := r.URL.Query().Get("ip"); v != "" {
|
if v := r.URL.Query().Get("ip"); v != "" {
|
||||||
f.IP = v
|
f.IP = v
|
||||||
@@ -302,8 +309,8 @@ func logsHandler(db *sql.DB) http.HandlerFunc {
|
|||||||
logs := make([]map[string]interface{}, 0)
|
logs := make([]map[string]interface{}, 0)
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
var ts time.Time
|
var ts time.Time
|
||||||
var action, apiClientIP string
|
var action string
|
||||||
var ip, reason sql.NullString
|
var ip, reason, apiClientIP sql.NullString
|
||||||
var ttlSeconds sql.NullInt64
|
var ttlSeconds sql.NullInt64
|
||||||
if err := rows.Scan(&ts, &action, &ip, &ttlSeconds, &reason, &apiClientIP); err != nil {
|
if err := rows.Scan(&ts, &action, &ip, &ttlSeconds, &reason, &apiClientIP); err != nil {
|
||||||
continue
|
continue
|
||||||
@@ -311,7 +318,7 @@ func logsHandler(db *sql.DB) http.HandlerFunc {
|
|||||||
entry := map[string]interface{}{
|
entry := map[string]interface{}{
|
||||||
"timestamp": ts,
|
"timestamp": ts,
|
||||||
"action": action,
|
"action": action,
|
||||||
"api_client_ip": apiClientIP,
|
"api_client_ip": apiClientIP.String,
|
||||||
"reason": reason.String,
|
"reason": reason.String,
|
||||||
}
|
}
|
||||||
if ip.Valid {
|
if ip.Valid {
|
||||||
@@ -333,13 +340,13 @@ func statusHandler(db *sql.DB) http.HandlerFunc {
|
|||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
var permCount int
|
var permCount int
|
||||||
var tempCount int
|
var tempCount int
|
||||||
dbOK := false
|
dbOK := true
|
||||||
|
|
||||||
if err := db.QueryRow(`SELECT COUNT(*) FROM perm_whitelist`).Scan(&permCount); err == nil {
|
if err := db.QueryRow(`SELECT COUNT(*) FROM perm_whitelist`).Scan(&permCount); err != nil {
|
||||||
dbOK = true
|
dbOK = false
|
||||||
}
|
}
|
||||||
if err := db.QueryRow(`SELECT COUNT(*) FROM temp_whitelist WHERE expires_at > ?`, time.Now().Format(time.RFC3339)).Scan(&tempCount); err == nil {
|
if err := db.QueryRow(`SELECT COUNT(*) FROM temp_whitelist WHERE expires_at > ?`, time.Now().Format(time.RFC3339)).Scan(&tempCount); err != nil {
|
||||||
dbOK = true
|
dbOK = false
|
||||||
}
|
}
|
||||||
|
|
||||||
health := map[string]interface{}{
|
health := map[string]interface{}{
|
||||||
|
|||||||
Reference in New Issue
Block a user