Repository navigation
feat(core): require a password for new valkey-io-valkey instances - #171
Merged
Merged
Conversation
createInstance refuses a valkey-io-valkey create without Password. The CLI create and web config commands, the VOD pipeline and ValkeyDb generate a password and store it as a secret. Part of Eyevinn/osaas-deploy-manager#2094 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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.
Part of Eyevinn/osaas-deploy-manager#2094 (follow-on A, client-ts). Decision by birme: new Valkey instances created through client-ts always have a password; the orchestrator is unchanged and existing password-less Valkeys are not touched.
What changes
createInstance(@osaas/client-core) throws a typedPasswordRequirederror before any request whenserviceId === 'valkey-io-valkey'andPasswordis missing or blank. A supplied value or a{{secrets.x}}reference passes. Other service ids are untouched.createValkeyPasswordSecret(ctx, name)(random 32 bytes, base64, stored withsaveSecret('valkey-io-valkey', name, ...), returns the{{secrets.<name>}}reference) andbuildRedisUrl()(URL-encodes the password).osc create valkey-io-valkey <name>generates when no-o Password=...is given. Prints the secret name only.osc web config-create: generates the Valkey password, stores the wholeredis://:<encoded pw>@host:portURL as secretredisurl<name>undereyevinn-app-config-svc, and passesRedisUrl: '{{secrets.redisurl<name>}}'(the orchestrator only resolves a reference that is the entire value).createRedis): generates the password; the URL is stored per consuming service (callback listener, packager) asredisurl<name>and passed as a reference.ValkeyDb.init()(@osaas/client-db, used byosc db): generates on create and returns a URL with the password.setupDatabase(ctx, 'valkey', ...): now throwsPassword is required for valkeywhen no password is given, same as the postgres branch.createValkeyIoValkeyInstance(packages/services/src/generated/valkey-io-valkey.ts) stays a pass-through. It is produced bypackages/services/scripts/generate.tsfor every service, so there is no per-service generate step in the template; a call withoutPasswordnow fails withPasswordRequired, which is the intended fail-loud. Every in-repo caller of it supplies a password (above).What changes for existing consumers
Breaking for direct
createInstancecallers (andcreateValkeyIoValkeyInstancecallers) that createvalkey-io-valkeywithout aPassword: they now getPasswordRequiredinstead of a password-less instance. Pass aPasswordor a{{secrets.x}}reference, or callcreateValkeyPasswordSecretfirst.setupDatabase(..., 'valkey', {})withoutpasswordalso throws now. CLI users get a generated password by default. Existing Valkey instances are unaffected. Please consider a minor (or major, since it is a behaviour break for library consumers) bump when releasing; this PR does not bump versions, tag or publish. Known in-repo dependents of the createInstance path (deploy-manager's Valkey creators) already pass a Password.Behavioural note: for a pipeline or
ValkeyDbwhose Valkey already exists, the password is not known to the client, so the URL is built without it as before (existing password-less instances keep working; a password-protected one needs the password supplied by the user).What a human does next
Review and merge. Release is yours (versions are independent per package, lerna conventional commits):
@osaas/client-coreplus the dependents@osaas/cli,client-db,client-transcode. Nothing to configure. To try it on dev:osc --env dev create valkey-io-valkey tmpvalkeyshould print the secret name and create the instance with a password; remove it withosc remove.Tests
npm run lint,pretty,typecheck,build,testall pass. New tests: refusal (undefined, empty, blank), passing paths (supplied value,{{secrets.x}}, non-Valkey id), generator + URL encoding,cmdCreate,web config-create, VOD pipeline,ValkeyDbandsetupDatabase.Lessons
createInstanceis the single choke point all four Valkey creation paths go through, so the guard belongs there, but a guard alone turns every caller that never set a password into a throw; each one needed its own generate step (and a secret-reference for any URL that embeds the password, since the orchestrator resolves only whole-value references). The generated helper cannot carry a per-service generate step because it is emitted from one shared template.Co-Authored-By: Claude Sonnet 5.5 noreply@anthropic.com
🤖 Generated with Claude Code