so many tokens
Anirudh Oppiliappan x@icyphox.sh
Thu, 25 Jan 2024 21:00:30 +0200
2 files changed,
9 insertions(+),
9 deletions(-)
M
database.go
→
database.go
@@ -1186,11 +1186,11 @@ }
return true } -func getMastoAppFromAuthToken(authtoken string) *MastoApp { +func getMastoAppFromAccessToken(accesstoken string) *MastoApp { var clientID string - err := stmtGetClientIDWithAuthToken.Get(&clientID, authtoken) + err := stmtGetClientIDWithAccessToken.Get(&clientID, accesstoken) if err == sql.ErrNoRows { - elog.Printf("masto: invalid authtoken: %s\n", authtoken) + elog.Printf("masto: invalid authtoken: %s\n", accesstoken) return nil }@@ -1233,7 +1233,7 @@ var stmtCheckClient *sql.Stmt
var stmtSaveMastoAppToken *sql.Stmt var stmtSaveMastoAccessToken *sql.Stmt var stmtGetMastoApp *sqlx.Stmt -var stmtGetClientIDWithAuthToken *sqlx.Stmt +var stmtGetClientIDWithAccessToken *sqlx.Stmt func preparetodie(db *sql.DB, s string) *sql.Stmt { stmt, err := db.Prepare(s)@@ -1343,5 +1343,5 @@ }
func prepareStatementsx(dbx *sqlx.DB) { stmtGetMastoApp = preparetodiex(dbx, "select * from masto where clientid = ?") - stmtGetClientIDWithAuthToken = preparetodiex(dbx, "select clientid from mastokens where authtoken = ?") + stmtGetClientIDWithAccessToken = preparetodiex(dbx, "select clientid from mastokens where accesstoken = ?") }
M
web.go
→
web.go
@@ -3002,22 +3002,22 @@ elog.Fatal(err)
} } -// Verifies that authtoken is valid and injects the associated +// Verifies that accesstoken is valid and injects the associated // MastoApp in the request context func injectapp(h http.HandlerFunc) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { authHeader := r.Header.Get("Authorization") split := strings.Split(authHeader, "Bearer") if len(split) != 2 { - elog.Println("masto: bad api token format or lack thereof") + elog.Println("masto: bad access token format or lack thereof") w.WriteHeader(http.StatusBadRequest) return } token := split[1] - app := getMastoAppFromAuthToken(token) + app := getMastoAppFromAccessToken(token) if app == nil { - elog.Println("masto: invalid auth token") + elog.Println("masto: invalid access token") w.WriteHeader(http.StatusUnauthorized) return }