Generate a random key ID on registration
This commit is contained in:
parent
949d1fc2ad
commit
09417b5147
5 changed files with 47 additions and 10 deletions
|
@ -56,10 +56,10 @@ func getDefaultHandler(isCaddyAuth bool) http.Handler {
|
|||
|
||||
if isCaddyAuth {
|
||||
w.Header().Add("Remote-User", attr)
|
||||
} else {
|
||||
msg := fmt.Sprintf("hello, %s!", attr)
|
||||
w.Write([]byte(msg))
|
||||
}
|
||||
|
||||
msg := fmt.Sprintf("hello, %s!", attr)
|
||||
w.Write([]byte(msg))
|
||||
}
|
||||
|
||||
return http.HandlerFunc(handler)
|
||||
|
@ -90,7 +90,14 @@ func getRegistrationHandler(keyDir keydirectory.RegistrationDirectory) http.Hand
|
|||
|
||||
fmt.Printf("Registering %s key for %s\n", alg, request.UserId)
|
||||
|
||||
keyDir.RegisterKey(key, alg, request.UserId)
|
||||
keyId, err := keyDir.RegisterKey(key, alg, request.UserId)
|
||||
|
||||
if err != nil {
|
||||
http.Error(w, fmt.Sprintf("Server error - %s", err), 500)
|
||||
return
|
||||
}
|
||||
|
||||
w.Write([]byte(keyId))
|
||||
}
|
||||
|
||||
return http.HandlerFunc(handler)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue