From 23d7de0db09817c3eccfc2b93bed0601eb19600a Mon Sep 17 00:00:00 2001 From: Lewis Date: Wed, 10 Jun 2026 16:39:01 +0300 Subject: [PATCH] xrpc/serviceauth: didweb svc auth colon parameterization Lewis: May this revision serve well! --- appview/oauth/oauth.go | 3 ++- knotserver/config/config.go | 4 ++-- spindle/config/config.go | 4 ++-- xrpc/serviceauth/service_auth.go | 5 +++++ 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/appview/oauth/oauth.go b/appview/oauth/oauth.go index eddd001c..e9953cba 100644 --- a/appview/oauth/oauth.go +++ b/appview/oauth/oauth.go @@ -24,6 +24,7 @@ import ( "tangled.org/core/appview/db" "tangled.org/core/idresolver" "tangled.org/core/rbac" + "tangled.org/core/xrpc/serviceauth" ) const ( @@ -399,7 +400,7 @@ func WithTimeout(timeout time.Duration) ServiceClientOpt { } func (s *ServiceClientOpts) Audience() string { - return fmt.Sprintf("did:web:%s", s.service) + return serviceauth.DidWeb(s.service).String() } func (s *ServiceClientOpts) Host() string { diff --git a/knotserver/config/config.go b/knotserver/config/config.go index 994ff73a..e6bcd92b 100644 --- a/knotserver/config/config.go +++ b/knotserver/config/config.go @@ -2,10 +2,10 @@ package config import ( "context" - "fmt" "github.com/bluesky-social/indigo/atproto/syntax" "github.com/sethvargo/go-envconfig" + "tangled.org/core/xrpc/serviceauth" ) type Repo struct { @@ -36,7 +36,7 @@ type Git struct { } func (s Server) Did() syntax.DID { - return syntax.DID(fmt.Sprintf("did:web:%s", s.Hostname)) + return serviceauth.DidWeb(s.Hostname) } type Config struct { diff --git a/spindle/config/config.go b/spindle/config/config.go index 332355ba..990b2941 100644 --- a/spindle/config/config.go +++ b/spindle/config/config.go @@ -2,10 +2,10 @@ package config import ( "context" - "fmt" "github.com/bluesky-social/indigo/atproto/syntax" "github.com/sethvargo/go-envconfig" + "tangled.org/core/xrpc/serviceauth" ) type Server struct { @@ -35,7 +35,7 @@ type Tap struct { } func (s Server) Did() syntax.DID { - return syntax.DID(fmt.Sprintf("did:web:%s", s.Hostname)) + return serviceauth.DidWeb(s.Hostname) } type Secrets struct { diff --git a/xrpc/serviceauth/service_auth.go b/xrpc/serviceauth/service_auth.go index 5aaf6cf8..a5a31bc9 100644 --- a/xrpc/serviceauth/service_auth.go +++ b/xrpc/serviceauth/service_auth.go @@ -8,6 +8,7 @@ import ( "strings" "github.com/bluesky-social/indigo/atproto/auth" + "github.com/bluesky-social/indigo/atproto/syntax" "tangled.org/core/idresolver" "tangled.org/core/log" xrpcerr "tangled.org/core/xrpc/errors" @@ -15,6 +16,10 @@ import ( const ActorDid string = "ActorDid" +func DidWeb(hostname string) syntax.DID { + return syntax.DID("did:web:" + strings.ReplaceAll(hostname, ":", "%3A")) +} + type ServiceAuth struct { logger *slog.Logger resolver *idresolver.Resolver -- 2.51.2