An implementation of the ATProto statusphere example app but in Go

update the oauth routes and update the readme

+8 -10
+3 -3
cmd/main.go
··· 66 scopes := []string{"atproto", "transition:generic"} 67 if host == "" { 68 config = oauth.NewLocalhostConfig( 69 - fmt.Sprintf("http://127.0.0.1%s/oauth/callback", bind), 70 scopes, 71 ) 72 slog.Info("configuring localhost OAuth client", "CallbackURL", config.CallbackURL) 73 } else { 74 config = oauth.NewPublicConfig( 75 - fmt.Sprintf("%s/oauth/client-metadata.json", host), 76 - fmt.Sprintf("%s/oauth/oauth-callback", host), 77 scopes, 78 ) 79 }
··· 66 scopes := []string{"atproto", "transition:generic"} 67 if host == "" { 68 config = oauth.NewLocalhostConfig( 69 + fmt.Sprintf("http://127.0.0.1%s/oauth-callback", bind), 70 scopes, 71 ) 72 slog.Info("configuring localhost OAuth client", "CallbackURL", config.CallbackURL) 73 } else { 74 config = oauth.NewPublicConfig( 75 + fmt.Sprintf("%s/oauth-client-metadata.json", host), 76 + fmt.Sprintf("%s/oauth-callback", host), 77 scopes, 78 ) 79 }
+1 -3
readme.md
··· 2 3 This is an implementation of the example [ATProto application Statusphere](https://atproto.com/guides/applications) but in Go. 4 5 - It makes use of an ATProto OAuth [library](https://github.com/haileyok/atproto-oauth-golang). Shout out to [Hailey](https://bsky.app/profile/hailey.at) for implementing a Go OAuth library! 6 - 7 ### What is the Statusphere app? 8 If you haven't read the [ATProto application Statusphere](https://atproto.com/guides/applications) guide about what this is, here is a quick summary. 9 ··· 17 18 A few environment variables are required to run the app. Use the `example.env` file as a template and store your environment variables in a `.env` file. 19 20 - * PRIVATEJWKS: This is a private JWKS. You can generate one using the same Go OAuth [library](https://github.com/haileyok/atproto-oauth-golang). Once created, base64 encode it so it's easier to store in your env. 21 * SESSION_KEY: This can be anything as it's what's used to encrypt session data sent to/from the client. 22 * HOST: This needs to be a http URL where the server is running. For local dev I suggest using something like [ngrok](https://ngrok.com) to run you app locally and make it accessable externally. This is important for OAuth as the callback URL configured needs to be a publically accessable. 23 * DATABASE_MOUNT_PATH: This is where you wish the mysql database to be located.
··· 2 3 This is an implementation of the example [ATProto application Statusphere](https://atproto.com/guides/applications) but in Go. 4 5 ### What is the Statusphere app? 6 If you haven't read the [ATProto application Statusphere](https://atproto.com/guides/applications) guide about what this is, here is a quick summary. 7 ··· 15 16 A few environment variables are required to run the app. Use the `example.env` file as a template and store your environment variables in a `.env` file. 17 18 + * PRIVATEJWKS: This is a private JWKS. You can generate one using this Go OAuth [library](https://github.com/haileyok/atproto-oauth-golang). Once created, base64 encode it so it's easier to store in your env. 19 * SESSION_KEY: This can be anything as it's what's used to encrypt session data sent to/from the client. 20 * HOST: This needs to be a http URL where the server is running. For local dev I suggest using something like [ngrok](https://ngrok.com) to run you app locally and make it accessable externally. This is important for OAuth as the callback URL configured needs to be a publically accessable. 21 * DATABASE_MOUNT_PATH: This is where you wish the mysql database to be located.
+4 -4
server.go
··· 79 mux.HandleFunc("POST /logout", srv.HandleLogOut) 80 81 mux.HandleFunc("/public/app.css", serveCSS) 82 - mux.HandleFunc("/oauth/jwks.json", srv.serveJwks) 83 - mux.HandleFunc("/oauth/client-metadata.json", srv.serveClientMetadata) 84 - mux.HandleFunc("/oauth/oauth-callback", srv.handleOauthCallback) 85 86 addr := fmt.Sprintf("0.0.0.0:%d", port) 87 srv.httpserver = &http.Server{ ··· 140 metadata.ClientName = &clientName 141 metadata.ClientURI = &s.host 142 if s.oauthClient.Config.IsConfidential() { 143 - jwksURI := fmt.Sprintf("%s/oauth/jwks.json", r.Host) 144 metadata.JWKSURI = &jwksURI 145 } 146
··· 79 mux.HandleFunc("POST /logout", srv.HandleLogOut) 80 81 mux.HandleFunc("/public/app.css", serveCSS) 82 + mux.HandleFunc("/jwks.json", srv.serveJwks) 83 + mux.HandleFunc("/oauth-client-metadata.json", srv.serveClientMetadata) 84 + mux.HandleFunc("/oauth-callback", srv.handleOauthCallback) 85 86 addr := fmt.Sprintf("0.0.0.0:%d", port) 87 srv.httpserver = &http.Server{ ··· 140 metadata.ClientName = &clientName 141 metadata.ClientURI = &s.host 142 if s.oauthClient.Config.IsConfidential() { 143 + jwksURI := fmt.Sprintf("%s/jwks.json", r.Host) 144 metadata.JWKSURI = &jwksURI 145 } 146