Monorepo for Tangled tangled.org

appview/oauth: add client name and uri to metadata responses #720

merged opened by oppi.li targeting master from push-mklsmqlkzqwo
Labels

None yet.

assignee

None yet.

Participants 2
AT URI
at://did:plc:qfpnj4og54vl56wngdriaxug/sh.tangled.repo.pull/3m4b74vhq4422
+10 -8
Interdiff #0 โ†’ #1
+2 -5
appview/oauth/handler.go
··· 30 } 31 32 func (o *OAuth) clientMetadata(w http.ResponseWriter, r *http.Request) { 33 - clientName := "Tangled" 34 - clientUri := "tangled.org" 35 - 36 doc := o.ClientApp.Config.ClientMetadata() 37 doc.JWKSURI = &o.JwksUri 38 - doc.ClientName = &clientName 39 - doc.ClientURI = &clientUri 40 41 w.Header().Set("Content-Type", "application/json") 42 if err := json.NewEncoder(w).Encode(doc); err != nil {
··· 30 } 31 32 func (o *OAuth) clientMetadata(w http.ResponseWriter, r *http.Request) { 33 doc := o.ClientApp.Config.ClientMetadata() 34 doc.JWKSURI = &o.JwksUri 35 + doc.ClientName = &o.ClientName 36 + doc.ClientURI = &o.ClientUri 37 38 w.Header().Set("Content-Type", "application/json") 39 if err := json.NewEncoder(w).Encode(doc); err != nil {
+2 -1
appview/config/config.go
··· 13 CookieSecret string `env:"COOKIE_SECRET, default=00000000000000000000000000000000"` 14 DbPath string `env:"DB_PATH, default=appview.db"` 15 ListenAddr string `env:"LISTEN_ADDR, default=0.0.0.0:3000"` 16 - AppviewHost string `env:"APPVIEW_HOST, default=https://tangled.sh"` 17 Dev bool `env:"DEV, default=false"` 18 DisallowedNicknamesFile string `env:"DISALLOWED_NICKNAMES_FILE"` 19
··· 13 CookieSecret string `env:"COOKIE_SECRET, default=00000000000000000000000000000000"` 14 DbPath string `env:"DB_PATH, default=appview.db"` 15 ListenAddr string `env:"LISTEN_ADDR, default=0.0.0.0:3000"` 16 + AppviewHost string `env:"APPVIEW_HOST, default=https://tangled.org"` 17 + AppviewName string `env:"APPVIEW_Name, default=Tangled"` 18 Dev bool `env:"DEV, default=false"` 19 DisallowedNicknamesFile string `env:"DISALLOWED_NICKNAMES_FILE"` 20
+6 -2
appview/oauth/oauth.go
··· 26 SessStore *sessions.CookieStore 27 Config *config.Config 28 JwksUri string 29 Posthog posthog.Client 30 Db *db.DB 31 Enforcer *rbac.Enforcer ··· 34 } 35 36 func New(config *config.Config, ph posthog.Client, db *db.DB, enforcer *rbac.Enforcer, res *idresolver.Resolver, logger *slog.Logger) (*OAuth, error) { 37 - 38 var oauthConfig oauth.ClientConfig 39 var clientUri string 40 - 41 if config.Core.Dev { 42 clientUri = "http://127.0.0.1:3000" 43 callbackUri := clientUri + "/oauth/callback" ··· 61 clientApp := oauth.NewClientApp(&oauthConfig, authStore) 62 clientApp.Dir = res.Directory() 63 64 return &OAuth{ 65 ClientApp: clientApp, 66 Config: config, 67 SessStore: sessStore, 68 JwksUri: jwksUri, 69 Posthog: ph, 70 Db: db, 71 Enforcer: enforcer,
··· 26 SessStore *sessions.CookieStore 27 Config *config.Config 28 JwksUri string 29 + ClientName string 30 + ClientUri string 31 Posthog posthog.Client 32 Db *db.DB 33 Enforcer *rbac.Enforcer ··· 36 } 37 38 func New(config *config.Config, ph posthog.Client, db *db.DB, enforcer *rbac.Enforcer, res *idresolver.Resolver, logger *slog.Logger) (*OAuth, error) { 39 var oauthConfig oauth.ClientConfig 40 var clientUri string 41 if config.Core.Dev { 42 clientUri = "http://127.0.0.1:3000" 43 callbackUri := clientUri + "/oauth/callback" ··· 61 clientApp := oauth.NewClientApp(&oauthConfig, authStore) 62 clientApp.Dir = res.Directory() 63 64 + clientName := config.Core.AppviewName 65 + 66 return &OAuth{ 67 ClientApp: clientApp, 68 Config: config, 69 SessStore: sessStore, 70 JwksUri: jwksUri, 71 + ClientName: clientName, 72 + ClientUri: clientUri, 73 Posthog: ph, 74 Db: db, 75 Enforcer: enforcer,

History

2 rounds 1 comment
sign up or login to add to the discussion
oppi.li submitted #1
1 commit
expand
appview/oauth: add client name and uri to metadata responses
expand 0 comments
pull request successfully merged
oppi.li submitted #0
1 commit
expand
appview/oauth: add client name and uri to metadata responses
expand 1 comment

I think those should be rather configured from oauth.New() function in appview/oauth/oauth.go. Also the ClientURI should be configurable with TANGLED_APPVIEW_HOST.