mirror of
https://github.com/DeBrosOfficial/network.git
synced 2025-10-06 10:39:06 +00:00
This commit adds wallet-based authentication to protected CLI commands by removing the manual auth command and automatically prompting for credentials when needed. Protected commands will check for valid credentials and trigger the auth
24 lines
743 B
Go
24 lines
743 B
Go
package gateway
|
|
|
|
import (
|
|
"context"
|
|
|
|
"git.debros.io/DeBros/network/pkg/client"
|
|
)
|
|
|
|
func (g *Gateway) resolveNamespaceID(ctx context.Context, ns string) (interface{}, error) {
|
|
// Use internal context to bypass authentication for system operations
|
|
internalCtx := client.WithInternalAuth(ctx)
|
|
db := g.client.Database()
|
|
if _, err := db.Query(internalCtx, "INSERT OR IGNORE INTO namespaces(name) VALUES (?)", ns); err != nil {
|
|
return nil, err
|
|
}
|
|
res, err := db.Query(internalCtx, "SELECT id FROM namespaces WHERE name = ? LIMIT 1", ns)
|
|
if err != nil || res == nil || res.Count == 0 || len(res.Rows) == 0 || len(res.Rows[0]) == 0 {
|
|
return nil, err
|
|
}
|
|
return res.Rows[0][0], nil
|
|
}
|
|
|
|
// Deprecated: seeding API keys from config is removed.
|