mirror of
https://github.com/floci-io/floci.git
synced 2026-11-23 06:00:46 -05:00
* feat(cognito): add AdminLinkProviderForUser Linking a federated identity to an existing user pool user returned 400 UnsupportedOperation, because the action had no arm in the CognitoJsonHandler switch and fell through to the default case. Add the action to the handler and service. The link is recorded as an entry in the destination user's `identities` attribute, matching the JSON array AWS documents: userId, providerName, providerType, issuer, primary and dateCreated. CognitoUser.attributes is already a free-form map and AdminGetUser emits every attribute as a UserAttribute, so the linked identity surfaces without a model change. dateCreated is stored in epoch milliseconds. That differs from the seconds this service uses for its own user timestamps, but it is what AWS emits in the identities attribute and the ID token claim. providerType is only set when the source provider name is one of the provider types AWS also uses as a name (Facebook, Google, LoginWithAmazon, SignInWithApple). SAML and OIDC types, and issuer, are properties of a registered IdP, which the emulator does not model, so they stay null rather than being guessed. A source identity may be linked to at most one user per pool; a conflicting link throws AliasExistsException, a documented error of this operation. Source provider names are not validated against a configured IdP, and the five-identity cap is not enforced. Both are noted as deliberate divergences in the pull request. Closes #1563 * fix(cognito): validate link fields and serialize the uniqueness check AdminLinkProviderForUser accepted requests with a missing SourceUser ProviderName or ProviderAttributeValue: path().asText() turns absent fields into empty strings, so a bad request returned 200 and persisted an identity with an empty providerName or userId. Require the three fields up front and answer InvalidParameterException, matching how this service already reports missing required input. The uniqueness check and the write could also interleave: two concurrent links of the same source identity to different users could both pass the scan before either wrote. Wrap the check and the write in synchronized (pool), the pattern the tag operations already use. * fix(cognito): serialize identity links on a stable monitor The uniqueness check locked the UserPool object, but updateUserPool replaces the stored instance (convertValue copy + poolStore.put), so two links racing an update could hold different monitors and both pass the scan. Serialize on a dedicated lock instead, declared beside the one method it guards. Dropping the describeUserPool lookup also changes the unknown-pool error source: adminGetUser reports it as ResourceNotFoundException 400, which is how every sibling admin user mutator already reports it. Verified with an 8-thread probe linking the same source identity to eight users: one winner and seven AliasExistsException with the lock, eight winners without it.