serverconfig: remove hard-coded search owner in genconfig.

Change-Id: I9161bcab5f9deb2ac8b0691c6858ae8615f435ab
This commit is contained in:
Brad Fitzpatrick 2012-04-12 11:39:53 -07:00
parent 7b8105d561
commit fbeb934c17
1 changed files with 15 additions and 2 deletions

View File

@ -22,7 +22,9 @@ import (
"path/filepath" "path/filepath"
"strings" "strings"
"camlistore.org/pkg/blobref"
"camlistore.org/pkg/jsonconfig" "camlistore.org/pkg/jsonconfig"
"camlistore.org/pkg/jsonsign"
) )
// various parameters derived from the high-level user config // various parameters derived from the high-level user config
@ -32,6 +34,7 @@ type configPrefixesParams struct {
keyId string keyId string
indexerPath string indexerPath string
blobPath string blobPath string
searchOwner *blobref.BlobRef
} }
func addUiConfig(prefixes *jsonconfig.Obj, uiPrefix string, published ...interface{}) { func addUiConfig(prefixes *jsonconfig.Obj, uiPrefix string, published ...interface{}) {
@ -121,7 +124,7 @@ func genLowLevelPrefixes(params *configPrefixesParams) jsonconfig.Obj {
ob["handlerArgs"] = map[string]interface{}{ ob["handlerArgs"] = map[string]interface{}{
"secretRing": params.secretRing, "secretRing": params.secretRing,
"keyId": params.keyId, "keyId": params.keyId,
"publicKeyDest": "/bs/", "publicKeyDest": "/bs-and-index/",
} }
prefixes["/sighelper/"] = ob prefixes["/sighelper/"] = ob
@ -162,7 +165,7 @@ func genLowLevelPrefixes(params *configPrefixesParams) jsonconfig.Obj {
ob["handler"] = "search" ob["handler"] = "search"
ob["handlerArgs"] = map[string]interface{}{ ob["handlerArgs"] = map[string]interface{}{
"index": params.indexerPath, "index": params.indexerPath,
"owner": "sha1-f2b0b7da718b97ce8c31591d8ed4645c777f3ef4", "owner": params.searchOwner.String(),
} }
prefixes["/my-search/"] = ob prefixes["/my-search/"] = ob
@ -218,11 +221,21 @@ func GenLowLevelConfig(conf *Config) (lowLevelConf *Config, err error) {
indexerPath = "/index-mem/" indexerPath = "/index-mem/"
} }
entity, err := jsonsign.EntityFromSecring(keyId, secretRing)
if err != nil {
return nil, err
}
armoredPublicKey, err := jsonsign.ArmoredPublicKey(entity)
if err != nil {
return nil, err
}
prefixesParams := &configPrefixesParams{ prefixesParams := &configPrefixesParams{
secretRing: secretRing, secretRing: secretRing,
keyId: keyId, keyId: keyId,
indexerPath: indexerPath, indexerPath: indexerPath,
blobPath: blobPath, blobPath: blobPath,
searchOwner: blobref.SHA1FromString(armoredPublicKey),
} }
prefixes := genLowLevelPrefixes(prefixesParams) prefixes := genLowLevelPrefixes(prefixesParams)