veyron/services/identity: Added extension to add caveats form for
identity server UI.

* Extensions will be of the form email/<formvalue>
* This is dependent on the switch to principals because old model does
  not allow extensions with '/' in them.

Change-Id: I131a20453c23b629761bca29e514751cb05dfb0b
diff --git a/services/identity/googleoauth/handler.go b/services/identity/googleoauth/handler.go
index f008dce..9f7c044 100644
--- a/services/identity/googleoauth/handler.go
+++ b/services/identity/googleoauth/handler.go
@@ -387,6 +387,11 @@
 		util.HTTPBadRequest(w, r, fmt.Errorf("Suspected request forgery: %v", err))
 		return
 	}
+	blessingExtension := r.FormValue("blessingExtension")
+	name := inputMacaroon.Email
+	if len(blessingExtension) > 0 {
+		name = name + security.ChainSeparator + blessingExtension
+	}
 	caveats, err := h.caveats(r)
 	if err != nil {
 		util.HTTPBadRequest(w, r, fmt.Errorf("failed to extract caveats: ", err))
@@ -396,7 +401,7 @@
 	m := blesser.BlessingMacaroon{
 		Creation: time.Now(),
 		Caveats:  caveats,
-		Name:     inputMacaroon.Email,
+		Name:     name,
 	}
 	if err := vom.NewEncoder(buf).Encode(m); err != nil {
 		util.HTTPServerError(w, fmt.Errorf("failed to encode BlessingsMacaroon: ", err))
diff --git a/services/identity/googleoauth/template.go b/services/identity/googleoauth/template.go
index f79b5bf..6f8638c 100644
--- a/services/identity/googleoauth/template.go
+++ b/services/identity/googleoauth/template.go
@@ -151,8 +151,14 @@
 </head>
 <body class="container">
 <form class="form-signin" method="POST" name="input" action="/google/{{.MacaroonRoute}}">
-<h2 class="form-signin-heading">Select Caveats on {{.Extension}}</h2>
+<h2 class="form-signin-heading">{{.Extension}}</h2>
 <input type="text" class="hidden" name="macaroon" value="{{.Macaroon}}">
+<div class="form-group">
+  <label for="blessing-extension">Extension</label>
+  <input name="blessingExtension" type="text" class="form-control" id="blessing-extension" placeholder="(optional) If set to foo, then blessings will be of the form {{.Extension}}/foo">
+</div>
+<br/>
+<h3 class="form-signin-heading">Select Caveats</h3>
 <div class="caveatRow row">
 <br/>
   <div class="col-md-4">