Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split away code for decoding root tokens into a function #10504

Closed
ptzianos opened this issue Dec 5, 2020 · 3 comments · Fixed by #10505
Closed

Split away code for decoding root tokens into a function #10504

ptzianos opened this issue Dec 5, 2020 · 3 comments · Fixed by #10505

Comments

@ptzianos
Copy link
Contributor

ptzianos commented Dec 5, 2020

Is your feature request related to a problem? Please describe.
When using the API client to generate a temporary root token using the unseal keys, there is no way of easily decoding the root token that is returned. The piece of code that performs this function is inside the command/operator_generate_root.go file and can't be re-used.

Describe the solution you'd like
Split away the code into a function that can be re-used by anyone who wants to create a temp root token using the API client

@PayalSasmal10
Copy link

can we decode the root token from this code using API?

@ptzianos
Copy link
Contributor Author

ptzianos commented Jan 5, 2021

@PayalSasmal10 the workflow that I had in mind (and that I implemented based on this) is that you get a new token via the API and then decode it using the helper function. so in pseudo-Go it looks like this:

var tempRootToken string
for i, unsealKey := range unsealKeys {
	resp, err := client.Sys().GenerateRootUpdate(string(unsealKey[:]), rootInitResp.OTP)
	if resp.Complete {
		tempRootToken, err = token.DecodeRootToken(resp.EncodedRootToken, rootInitResp.OTP, rootInitResp.OTPLength)
		break
	}
}

@PayalSasmal10
Copy link

Thanks @ptzianos . Waiting for merging this commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants