-
Notifications
You must be signed in to change notification settings - Fork 11
feat(input_schema): Enable secret objects #515
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
base: master
Are you sure you want to change the base?
Conversation
Thanks for the proposal. I have a few notes/questions:
|
Ah sorry, the first one is my fault, I forgot that cookies are an array when specifying it |
Yeah, that should be straightforward, in the same way as with objects
The issue is that if the type of the field is defined as We can add
Yeah it would be, this works the same as string field decryption and if the value doesn't look like it's encrypted no decryption is done at all. Value looks like it's encrypted means in this case that the object has field
There won't by any change in API call at all, since the input is provided unencrypted and is encrypted by API internally |
Hey, I understand that the representation was chosen so that the basic type is always matching, and it's not a problem for the validation. But the basic type (string/array/object) is all that can be validated, nothing else - so it's not very strong. So instead I'd go with something like Until it's decrypted, nobody should know what's inside (except the user). From the perspective of types, you'd have We can also use that later to cover the string case we have now. To compare it, the solution in the PR would look like this when you pass it encrypted:
And like this when you pass it un-encrypted:
Meaning that the encrypted case looks weird - we need a special representation for every type. I'd be more inclined to
And if passed as not-encrypted:
Meaning that the not-encrypted case looks weird - which is fine, because the encrypted is the default. I won't make it to the rest of the discussion, just wanted to chip in with this :) |
I don't see any additional value having the
Generally speaking with you suggestion we still wouldn't support encryption objects and arrays. Only one thing we can do is to add support for |
I only read this quickly, but I feel:
is a weird "Potemkin" JSON, which will not even be compatible with objects produced by our editors and now the newly introduced sub-schemas, so it only solves some cases, but not the others.
Is this really a problem? When you call an Actor via API, you pass a full unencrypted JSON input, which is validated as is, and encrypted when storing to KV-store. It's only when Actor one would fetch the JSON from KV-store they will receive an object which will not pass validation. But everyone should use |
Yes when you're calling an Actor via API, this should work as you are describing, but when you would start the Actor from UI, the encrypted input is stored right as you pasted it to UI input and this encrypted value is then used to call the API. And in this step we would be sending What we can do is to catch the error produced by JSON Schema and check if the field has
I supposed that the secret field wouldn't be able to define sub-schema, same as we're doing with properties like |
Thanks for the clarification. But it really feels like we're changing the external logic (and consequently the Actor specification that we want to make an open standard) just to make some internal implementation easier for us, which is a short-sighted way to design open systems. I'm sure there's some smarter way to do it. For example, we could prefix the encrypted JSON with Also I don't think it's a good idea to block sub-schemas for encrypted objects or arrays. For example, we want to use this new functionality for storing cookies, which need to have a specific format. If we don't validate what users enter in UI or use in API, it will be just another source of user errors and bad UX. We probably cut this corner back in the days when we designed encrypted value for strings, but let's not perpetuate that hack in the future if we can do it better now. CCing @mtrunkat for visibility |
Based on the issue:
This is proposal to enable
isSecret
boolean property forobject
fields in Input Schema.Currently this is available only for
string
fields with editors eithertextfield
ortextarea
.The
object
fields withisSecret: true
won't be able to specify some properties that "normal"object
fields can do, such as:default
,prefill
,patternKey
,patternValue
,minProperties
,maxProperties
.Editor can be only
json
orhidden
. This restriction is basically the same as with the secretstring
property.In addition to change in the Input Schema's JSON schema it's also needed to change the encryption/decryption logic.
If input is
string
, there is no change and the encrypted value is stored inENCRYPTED_VALUE:base64:base64
form.In case of
object
input, we need to keep the type of the encrypted value to be stillobject
because of validation of input in other stages.This propose to store encrypted objects as object with structure:
where the
secret
key, contains same string value as normal encrypted string property.When decrypting an encrypted value the logic is exactly the same as with string. We would check if the object has
secret
field and if the value is string that match the encrypted string regex.@apify/input_secrets
for encryption/decryption (it's part of this PR)apify._crypto
to decrypt secrets here is draft PR (I didn't test is yet), just to showcase what change would be needed there: feat(crypto): decrypt secret objects apify-sdk-python#482I didn't find any other place where would this change causing issues.