veyron/services/identity/identityd: Have the random identity be blessed
by the server.
Change-Id: Ibabb84c60fa315dd0d118b84e9b4911e781c0252
diff --git a/services/identity/handlers/random.go b/services/identity/handlers/random.go
index 540822a..7dbc8e0 100644
--- a/services/identity/handlers/random.go
+++ b/services/identity/handlers/random.go
@@ -14,7 +14,19 @@
type Random struct{ Runtime veyron2.Runtime }
func (h Random) ServeHTTP(w http.ResponseWriter, r *http.Request) {
- id, err := h.Runtime.NewIdentity(fmt.Sprintf("random:%d", rand.Intn(1000)))
+ name := fmt.Sprintf("random:%d", rand.Intn(1000))
+ id, err := h.Runtime.NewIdentity(name)
+ if err != nil {
+ util.HTTPServerError(w, err)
+ return
+ }
+ // Bless this with the identity of the runtime, valid forever (approximately 290 years)
+ blessing, err := h.Runtime.Identity().Bless(id.PublicID(), name, 0x7fffffffffffffff, nil)
+ if err != nil {
+ util.HTTPServerError(w, err)
+ return
+ }
+ id, err = id.Derive(blessing)
if err != nil {
util.HTTPServerError(w, err)
return