ai/at
1
0
Clone
12
oauth
syui edited this page 2025-06-17 04:15:37 +00:00

必要な値

pdsに設定する。

# Entrywayを明示的に無効化
PDS_ENTRYWAY_URL=
PDS_ENTRYWAY_DID=

# OAuth Provider設定
PDS_OAUTH_ISSUER=https://syu.is
PDS_OAUTH_PROVIDER_ENABLED=true

# その他の必須設定
PDS_HOSTNAME=syu.is
PDS_SERVICE_DID=did:web:syu.is
PDS_PUBLIC_URL=https://syu.is

裏でblueskyのserverを使って名前解決しますが、自分のplcを使うようにすれば解決できます。

this.oauthClient = await BrowserOAuthClient.load({
        clientId: this.getClientId(),
        handleResolver: pdsUrl,
        plcDirectoryUrl: pdsUrl === 'https://syu.is' ? 'https://plc.syu.is' : 'https://plc.directory',
});

解説

@atproto/oauth-providerが本体となる。

https://syu.is/@atproto/oauth-provider/~assets/file.css

curl -s https://syu.is/.well-known/oauth-authorization-server |jq . 
curl -s "https://syu.is/oauth/authorize?client_id=https://syui.ai/client-metadata.json&response_type=code&redirect_uri=https://syui.ai/oauth/callback"

裏でblueskyのserverを使って名前解決している

これは、自分のplcを使うようにすれば解決できます。

atproto-oauthは裏でblueskyのserverを使います。ですから、例えば、plc.directoryに登録されていないと成功しません。

# handle changeを行ったあとに更新されずdidでしかoauthできない。異なる名前で登録されている例

# did:plc:6qyecktefllvenje24fcxnie ...ok
# ai.syu.is ... ok
# ai.syui.ai ... no

$ curl -sL "https://syu.is/xrpc/com.atproto.identity.resolveHandle?handle=ai.syui.ai" |jq -r .did
did:plc:6qyecktefllvenje24fcxnie

$ curl -sL "https://plc.directory/did:plc:6qyecktefllvenje24fcxnie" | jq '.alsoKnownAs'
[
  "at://ai.syu.is"
]

didのhandleを確認

did=did:plc:6qyecktefllvenje24fcxnie
handle=ai.syui.ai
curl -sL "https://plc.directory/$did/log"|jq .
curl -sL "https://plc.syu.is/$did/log"|jq .
curl -sL "https://bsky.social/xrpc/com.atproto.identity.resolveHandle?handle=$handle" | jq .
curl -sL "https://syu.is/xrpc/com.atproto.identity.resolveHandle?handle=$handle" | jq .
curl -sL "https://public.api.bsky.app/xrpc/com.atproto.identity.resolveHandle?handle=$handle" | jq .
curl -sL "https://bsky.syu.is/xrpc/com.atproto.identity.resolveHandle?handle=$handle" | jq .

plc ...no
pds ...no
bsky ...yes