Update auth references from JWT to session tokens
- Remove PreviousTokenGraceUntil from RotateApiTokenResponse - Update comments and CLI flag descriptions - Remove grace period test from integration test - Update README Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
3683bd28dc
commit
75c2095f30
6 files changed
+13
-33
No files matched your search
@@ -108,15 +108,15 @@ client, err := elydora.NewClient(&elydora.Config{
|
||||
BaseURL: "https://...", // API base URL (default: https://api.elydora.com)
|
||||
TTLMs: 30000, // Operation TTL in ms (default: 30000)
|
||||
MaxRetries: 3, // Max retries on transient failures (default: 3)
|
||||
Token: "<jwt>", // JWT token for authenticated requests
|
||||
Token: "<token>", // API token for authenticated requests
|
||||
})
|
||||
```
|
||||
|
||||
### Client Methods
|
||||
|
||||
```go
|
||||
// Update the JWT token at runtime
|
||||
client.SetToken("new-jwt-token")
|
||||
// Update the API token at runtime
|
||||
client.SetToken("new-api-token")
|
||||
```
|
||||
|
||||
### Authentication
|
||||
@@ -128,7 +128,7 @@ reg, err := elydora.Register(baseURL, email, password,
|
||||
elydora.WithOrgName("Acme Corp"),
|
||||
)
|
||||
|
||||
// Login and receive a JWT
|
||||
// Login and receive a session token
|
||||
auth, err := elydora.Login(baseURL, email, password)
|
||||
|
||||
// Get current authenticated user profile
|
||||
|
||||
@@ -49,7 +49,7 @@ func Register(baseURL, email, password string, opts ...RegisterOption) (*AuthReg
|
||||
return &result, nil
|
||||
}
|
||||
|
||||
// Login authenticates a user and returns a JWT token.
|
||||
// Login authenticates a user and returns a session token.
|
||||
func Login(baseURL, email, password string) (*AuthLoginResponse, error) {
|
||||
if baseURL == "" {
|
||||
baseURL = defaultBaseURL
|
||||
|
||||
@@ -24,7 +24,7 @@ type Config struct {
|
||||
BaseURL string // defaults to "https://api.elydora.com"
|
||||
TTLMs int // defaults to 30000
|
||||
MaxRetries int // defaults to 3
|
||||
Token string // JWT token for authenticated requests
|
||||
Token string // API token for authenticated requests
|
||||
}
|
||||
|
||||
// Client is the Elydora SDK client.
|
||||
@@ -172,7 +172,7 @@ func (c *Client) doPost(path string, body interface{}, result interface{}) error
|
||||
return c.doRequest(http.MethodPost, path, body, result)
|
||||
}
|
||||
|
||||
// SetToken sets the JWT token used for authenticated API requests.
|
||||
// SetToken sets the API token used for authenticated API requests.
|
||||
func (c *Client) SetToken(token string) {
|
||||
c.token = token
|
||||
}
|
||||
+1
-1
@@ -69,7 +69,7 @@ func cmdInstall(args []string) {
|
||||
agentID := fs.String("agent-id", "", "Agent ID (required)")
|
||||
privateKey := fs.String("private-key", "", "Base64url-encoded Ed25519 private key seed (required)")
|
||||
kid := fs.String("kid", "", "Key ID (defaults to <agent-id>-key-1)")
|
||||
token := fs.String("token", "", "JWT token for authenticated requests (optional)")
|
||||
token := fs.String("token", "", "API token for authenticated requests (optional)")
|
||||
baseURL := fs.String("base-url", "https://api.elydora.com", "Elydora API base URL")
|
||||
|
||||
fs.Parse(args)
|
||||
|
||||
@@ -6,10 +6,8 @@ import (
|
||||
"encoding/base64"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
elydora "github.com/Elydora-Infrastructure/Elydora-Go-SDK"
|
||||
)
|
||||
@@ -91,8 +89,8 @@ func TestSDKCompatibilityAgainstLatestAPI(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("rotate api token failed: %v", err)
|
||||
}
|
||||
if rotateResp.Token == "" || rotateResp.PreviousTokenGraceUntil <= 0 {
|
||||
t.Fatalf("rotate response incomplete: %+v", rotateResp)
|
||||
if rotateResp.Token == "" {
|
||||
t.Fatalf("rotate response missing token: %+v", rotateResp)
|
||||
}
|
||||
|
||||
client.SetToken(rotateResp.Token)
|
||||
@@ -104,23 +102,6 @@ func TestSDKCompatibilityAgainstLatestAPI(t *testing.T) {
|
||||
t.Fatalf("rotated token org mismatch: got %s want %s", meWithRotated.User.OrgID, login.User.OrgID)
|
||||
}
|
||||
|
||||
// Old token should still be accepted during grace window.
|
||||
req, err := http.NewRequest(http.MethodGet, fmt.Sprintf("%s/v1/auth/me", baseURL), nil)
|
||||
if err != nil {
|
||||
t.Fatalf("create old token request: %v", err)
|
||||
}
|
||||
req.Header.Set("Authorization", "Bearer "+oldToken)
|
||||
req.Header.Set("Accept", "application/json")
|
||||
httpClient := &http.Client{Timeout: 20 * time.Second}
|
||||
oldTokenResp, err := httpClient.Do(req)
|
||||
if err != nil {
|
||||
t.Fatalf("old token grace request failed: %v", err)
|
||||
}
|
||||
oldTokenResp.Body.Close()
|
||||
if oldTokenResp.StatusCode != http.StatusOK {
|
||||
t.Fatalf("old token grace expected 200, got %d", oldTokenResp.StatusCode)
|
||||
}
|
||||
|
||||
_, err = client.RegisterAgent(&elydora.RegisterAgentRequest{
|
||||
AgentID: agentID,
|
||||
DisplayName: "Go SDK Compat Agent",
|
||||
|
||||
@@ -257,10 +257,9 @@ type IssueApiTokenResponse struct {
|
||||
}
|
||||
|
||||
type RotateApiTokenResponse struct {
|
||||
Token string `json:"token"`
|
||||
ExpiresAt *int64 `json:"expires_at"`
|
||||
TokenID string `json:"token_id"`
|
||||
PreviousTokenGraceUntil int64 `json:"previous_token_grace_until"`
|
||||
Token string `json:"token"`
|
||||
ExpiresAt *int64 `json:"expires_at"`
|
||||
TokenID string `json:"token_id"`
|
||||
}
|
||||
|
||||
type HealthResponse struct {
|
||||
|
||||
Reference in new issue
Block a user