Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions api/mobile.http
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ Authorization: Bearer {{mobileToken}}
Content-Type: application/json

{
"currentPassword": "wsmgz1akhoo24o",
"newPassword": "wsmgz1akhoo24o"
"currentPassword": "8f8ijpnuvemq7y",
"newPassword": "8f8ijpnuvemq7y"
}

###
Expand Down
39 changes: 35 additions & 4 deletions api/requests.http
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@baseUrl={{$dotenv CLOUD__URL}}
@credentials={{$dotenv CLOUD__CREDENTIALS}}
@mobileToken={{$dotenv MOBILE__TOKEN}}
@jwtToken={{$dotenv JWT__TOKEN}}
@phone={{$dotenv PHONE}}

###
Expand Down Expand Up @@ -34,7 +35,8 @@ Authorization: Basic {{credentials}}
###
POST {{baseUrl}}/3rdparty/v1/messages HTTP/1.1
Content-Type: application/json
Authorization: Basic {{credentials}}
# Authorization: Basic {{credentials}}
Authorization: Bearer {{jwtToken}}

{
"textMessage": {
Expand Down Expand Up @@ -78,11 +80,13 @@ Authorization: Basic {{credentials}}

###
GET {{baseUrl}}/3rdparty/v1/messages/Fc10ZyTRDVlqPjIm9Jbly HTTP/1.1
Authorization: Basic {{credentials}}
# Authorization: Basic {{credentials}}
Authorization: Bearer {{jwtToken}}

###
GET {{baseUrl}}/3rdparty/v1/messages HTTP/1.1
Authorization: Basic {{credentials}}
# Authorization: Basic {{credentials}}
Authorization: Bearer {{jwtToken}}

###
GET {{baseUrl}}/3rdparty/v1/messages?from=2025-01-01T00:00:00.000Z&to=2025-12-31T23:59:59Z&state=Pending&deviceId=fL2m4IirEvh9BvTf6TIB0&limit=50&offset=0 HTTP/1.1
Expand All @@ -101,7 +105,9 @@ Content-Type: application/json

###
GET {{baseUrl}}/3rdparty/v1/devices HTTP/1.1
Authorization: Basic {{credentials}}
# Authorization: Basic {{credentials}}
Authorization: Bearer {{jwtToken}}


###
DELETE {{baseUrl}}/3rdparty/v1/devices/gF0jEYiaG_x9sI1YFWa7a HTTP/1.1
Expand Down Expand Up @@ -192,6 +198,31 @@ Content-Type: application/json
}
}

###
POST {{baseUrl}}/3rdparty/v1/auth/token HTTP/1.1
Authorization: Basic {{credentials}}
Content-Type: application/json

{
"ttl": 3600,
"scopes": [
"messages:send",
"messages:read",
"devices:list",
"devices:write",
"webhooks:list",
"webhooks:write",
"settings:read",
"settings:write",
"logs:read"
]
}
Comment on lines +201 to +219
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Verify device and webhook scope names against defined constants.

The scope "devices:write" (line 212) may not match the permission constants defined in the codebase. Based on the past review comment, devices/permissions.go defines "devices:list" and "devices:delete". Confirm whether "devices:write" is a valid scope or if it should be "devices:delete".

Based on learnings from past review comments.


🏁 Script executed:

#!/bin/bash
# Description: Verify all defined permission scope constants across the codebase

echo "=== Defined Permission Scopes ==="
rg -n 'Scope.*=.*".*:.*"' --type go

echo ""
echo "=== Devices Permission Constants ==="
rg -n 'Scope' internal/sms-gateway/handlers/devices/permissions.go --type go

echo ""
echo "=== Webhooks Permission Constants ==="
rg -n 'Scope' internal/sms-gateway/handlers/webhooks/permissions.go --type go

Length of output: 1511


Change "devices:write" to "devices:delete" on line 212.

The scope "devices:write" does not exist in the codebase. The devices permissions constants define only "devices:list" and "devices:delete". Update the scope to match the available constant.

🤖 Prompt for AI Agents
In api/requests.http around lines 201 to 219, the scopes array includes
"devices:write" (line 212) which doesn't exist; replace "devices:write" with
"devices:delete" so the scope list matches the codebase constants (update the
JSON payload accordingly).


###
DELETE {{baseUrl}}/3rdparty/v1/auth/token/w8pxz0a4Fwa4xgzyCvSeC HTTP/1.1
Authorization: Basic {{credentials}}
Content-Type: application/json

###
GET http://localhost:3000/metrics HTTP/1.1

Expand Down
5 changes: 5 additions & 0 deletions cmd/sms-gateway/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ import (
// @securitydefinitions.basic ApiAuth
// @description User authentication

// @securitydefinitions.apikey JWTAuth
// @in header
// @name Authorization
// @description JWT authentication

// @securitydefinitions.apikey UserCode
// @in header
// @name Authorization
Expand Down
14 changes: 9 additions & 5 deletions configs/config.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,19 @@ cache: # cache config
url: memory:// # cache url (memory:// or redis://) [CACHE__URL]
pubsub: # pubsub config
url: memory:// # pubsub url (memory:// or redis://) [PUBSUB__URL]
jwt:
secret: # jwt secret (leave empty to disable JWT functionality) [JWT__SECRET]
ttl: 24h # jwt ttl [JWT__TTL]
issuer: # jwt issuer [JWT__ISSUER]

## Worker Config ##

tasks: # tasks config
messages_hashing:
interval: 168h # task execution interval in hours [TASKS__MESSAGES_HASHING__INTERVAL]
interval: 168h # task execution interval [TASKS__MESSAGES_HASHING__INTERVAL]
messages_cleanup:
interval: 24h # task execution interval in hours [TASKS__MESSAGES_CLEANUP__INTERVAL]
max_age: 720h # messages max age in hours [TASKS__MESSAGES_CLEANUP__MAX_AGE]
interval: 24h # task execution interval [TASKS__MESSAGES_CLEANUP__INTERVAL]
max_age: 720h # messages max age [TASKS__MESSAGES_CLEANUP__MAX_AGE]
devices_cleanup:
interval: 24h # task execution interval in hours [TASKS__DEVICES_CLEANUP__INTERVAL]
max_age: 8760h # inactive devices max age in hours [TASKS__DEVICES_CLEANUP__MAX_AGE]
interval: 24h # task execution interval [TASKS__DEVICES_CLEANUP__INTERVAL]
max_age: 8760h # inactive devices max age [TASKS__DEVICES_CLEANUP__MAX_AGE]
Loading
Loading