feat: add chunked storage - #10
Merged
Merged
Conversation
Member
Author
|
Was able to test this on an actual Windows installation: diff --git a/src/keyring.ts b/src/keyring.ts
index 6b91978..016ae0d 100644
--- a/src/keyring.ts
+++ b/src/keyring.ts
@@ -129,6 +129,7 @@ function parseCurrentCredentials(jsonString: string, allowChunked: boolean): Pro
const credentials = credentialsParseResult.data
if (credentials.mode === StorageMode.Chunked && allowChunked) {
+ console.log('Reading chunked credentials', credentials)
return readChunkedCredentials(credentials)
}
else if (credentials.mode === StorageMode.Chunked) {Output: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
This fixes the windows SSO bug where users who tried signing in via SSO received the following error:
After some research, it turns out Windows
CREDENTIALWservice hasCredentialBlobSizelimit of 5*512 bytes.Since SSO mode can take up to 5000 characters in keyring storage, this greatly exceeds the limits enforced by the platform.
Solution
To solve this, the normal payload is split to chunks which are simply fragments of the original credentials JSON. So the stringified
{"mode":"sso","accessToken":...}is split into chunks of up to 1024 characters (2048 bytes in UTF-16) and the parent entry becomes:The fields help later reconstruct/modify/delete the original saved credentials:
chunkCountspecifies how many chunks need to be read;checksumis theSHA-256checksum of the concatenation of all chunks - if any of the chunks are modified, the checksum would mismatch and invalidate the credentials;chunkIdis a unique identifier shared by the chunks which facilitates atomic re-writes of all chunks: first the new chunks are written with a newchunkId, then the parent entry (manifest) is updated, then the old chunks are deleted.The chunks stored in the keyring have the following label:
`aws-ssm-secrets/v2/chunk/${chunkId}/${index}`