policy/auth.go
func HostFromLogin(host string) string {
	urlElems := strings.Split(host, ".")
	hostPrefix := urlElems[0]
	elems := strings.Split(hostPrefix, "-")

	if len(elems) == 1 && elems[0] == "cm" {
		// accommodates micromoo host inference, such as "cm.rightscale.local" => "selfservice.rightscale.local"
		elems[0] = "governance"
	} else if len(elems) < 2 {
		// don't know how to compute this policy host; use the cm host
		return host
	} else {
		elems[len(elems)-2] = "governance"
	}
	policyHostPrefix := strings.Join(elems, "-")
	return strings.Join(append([]string{policyHostPrefix}, urlElems[1:]...), ".")
}
func HostFromLogin(host string) string {
	urlElems := strings.Split(host, ".")
	hostPrefix := urlElems[0]
	elems := strings.Split(hostPrefix, "-")

	if len(elems) == 1 && elems[0] == "cm" {
		// accommodates micromoo host inference, such as "cm.rightscale.local" => "selfservice.rightscale.local"
		elems[0] = "governance"
	} else if len(elems) < 2 {
		// don't know how to compute this policy host; use the cm host
		return host
	} else {
		elems[len(elems)-2] = "governance"
	}
	policyHostPrefix := strings.Join(elems, "-")
	return strings.Join(append([]string{policyHostPrefix}, urlElems[1:]...), ".")
}
// HostFromLogin returns the policy endpoint from its login endpoint.
// The following isn't great but seems better than having to enter by hand.