Exemplo n.º 1
0
// A JSON web token is a set of Base64 encoded strings separated by a period (.)
// When decoded, it will either be JSON text or a signature
// Here we print the full JSON text. We do not print the signature.
func dumpTokenDetailsRaw(w io.Writer, name string, encodedToken string) {
	jsonStrings, err := lightwave.ParseRawTokenDetails(encodedToken)
	if err != nil {
		fmt.Fprintf(w, "<unparseable>\n")
	}

	fmt.Fprintf(w, "%s:\n", name)
	for _, jsonString := range jsonStrings {
		var prettyJSON bytes.Buffer
		err = json.Indent(&prettyJSON, []byte(jsonString), "", "  ")
		if err == nil {
			fmt.Fprintf(w, "%s\n", string(prettyJSON.Bytes()))
		}
	}
	fmt.Fprintf(w, "Token: %s\n", encodedToken)
}
Exemplo n.º 2
0
// Parse the given token raw details.
func (api *AuthAPI) parseRawTokenDetails(token string) (jwtToken []string, err error) {
	jwtToken, err = lightwave.ParseRawTokenDetails(token)
	return jwtToken, err
}