allow masquerading webfinger

This commit is contained in:
Ted Unangst 2020-03-05 15:29:34 -05:00
parent 25a367d61c
commit ea7122f0ea
3 changed files with 11 additions and 2 deletions

View File

@ -171,6 +171,10 @@ To prepare a Twitter data archive, extract the twitter-longhash.zip file.
After unzipping the data archive, navigate to the tweet_media directory
and unzip any zip files contained within.
.Dl ./honk import username twitter source-directory
.Ss Advanced Options
To support separate mentions without a subdomain,
e.g. @user@example.com and https://honk.example.com/u/user,
add a ('masqname', 'example.com') row the config table of the database.
.Sh FILES
.Nm
files are split between the data directory and the view directory.

View File

@ -208,6 +208,7 @@ const (
)
var serverName string
var masqName string
var dataDir = "."
var viewDir = "."
var iconName = "icon.png"
@ -253,6 +254,10 @@ func main() {
getconfig("aboutmsg", &aboutMsg)
getconfig("loginmsg", &loginMsg)
getconfig("servername", &serverName)
getconfig("masqname", &masqName)
if masqName == "" {
masqName = serverName
}
getconfig("usersep", &userSep)
getconfig("honksep", &honkSep)
prepareStatements(db)

4
web.go
View File

@ -1997,7 +1997,7 @@ func fingerlicker(w http.ResponseWriter, r *http.Request) {
idx = strings.IndexByte(name, '@')
if idx != -1 {
name = name[:idx]
if name+"@"+serverName != orig {
if !(name+"@"+serverName == orig || name+"@"+masqName == orig) {
log.Printf("foreign request rejected")
name = ""
}
@ -2014,7 +2014,7 @@ func fingerlicker(w http.ResponseWriter, r *http.Request) {
}
j := junk.New()
j["subject"] = fmt.Sprintf("acct:%s@%s", user.Name, serverName)
j["subject"] = fmt.Sprintf("acct:%s@%s", user.Name, masqName)
j["aliases"] = []string{user.URL}
l := junk.New()
l["rel"] = "self"