this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

xrpc: crude support for admin auth

+9 -4
+9 -4
xrpc/xrpc.go
··· 3 3 import ( 4 4 "bytes" 5 5 "context" 6 + "encoding/base64" 6 7 "encoding/json" 7 8 "fmt" 8 9 "io" ··· 12 13 ) 13 14 14 15 type Client struct { 15 - Client *http.Client 16 - Auth *AuthInfo 17 - Host string 16 + Client *http.Client 17 + Auth *AuthInfo 18 + AdminToken *string 19 + Host string 18 20 } 19 21 20 22 func (c *Client) getClient() *http.Client { ··· 87 89 req.Header.Set("Content-Type", inpenc) 88 90 } 89 91 90 - if c.Auth != nil { 92 + // use admin auth if we have it configured and are doing a request that requires it 93 + if c.AdminToken != nil && (strings.HasPrefix(method, "com.atproto.admin.") || method == "com.atproto.account.createInviteCode") { 94 + req.Header.Set("Authorization", "Basic "+base64.StdEncoding.EncodeToString([]byte("admin:"+*c.AdminToken))) 95 + } else if c.Auth != nil { 91 96 req.Header.Set("Authorization", "Bearer "+c.Auth.AccessJwt) 92 97 } 93 98