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

feat: allow sharing of secrets publicly + public page for secret sharing #1923

Conversation

ShubhamPalriwala
Copy link
Contributor

Description 📣

  • Allows users to share secrets via Infisical without being authenticated thus helping in our GTM.
  • Authenticated users can do it from within their dashboard which allows them to keep a track of the secrets shared and their expiry details
  • New public page is at /shared/secret
  • Got rid of the Dragon 🐉

Public Page:

image

Shared Secret Page:

image

Type ✨

  • Bug fix
  • New feature
  • Breaking change
  • Documentation

Tests 🛠️

# Here's some code block to paste some code snippets

@maidul98
Copy link
Collaborator

maidul98 commented Jun 5, 2024

Bug: sometimes on first render, it will say expired even though it works again on next refresh.
Screenshot 2024-06-05 at 4 43 15 PM
This log might be related:

incoming request {"reqId":"req-3t","severity":"INFO","req":{"method":"GET","url":"/api/v1/secret-sharing/public/undefined?hashedHex=","hostname":"localhost:8080","remoteAddress":"192.168.96.1","remotePort":33220}}
infisical-dev-api              | [20:43:38.727] INFO (50): injectPermission: Injecting permissions for [permissionsForIdentity=9b5f450a-01aa-4581-bc3e-eeddd6fd9ff1] [type=user] {"severity":"INFO"}
infisical-dev-api              | [20:43:38.727] ERROR (50): [
infisical-dev-api              |   {
infisical-dev-api              |     "validation": "uuid",
infisical-dev-api              |     "code": "invalid_string",
infisical-dev-api              |     "message": "Invalid uuid",
infisical-dev-api              |     "path": [
infisical-dev-api              |       "id"
infisical-dev-api              |     ]
infisical-dev-api              |   }
infisical-dev-api              | ] {"reqId":"req-3t","severity":"ERROR"}
infisical-dev-api              |     err: {
infisical-dev-api              |       "type": "ZodError",
infisical-dev-api              |       "message": "[\n  {\n    \"validation\": \"uuid\",\n    \"code\": \"invalid_string\",\n    \"message\": \"Invalid uuid\",\n    \"path\": [\n      \"id\"\n    ]\n  }\n]",
infisical-dev-api              |       "stack":
infisical-dev-api              |           ZodError: [
infisical-dev-api              |             {
infisical-dev-api              |               "validation": "uuid",
infisical-dev-api              |               "code": "invalid_string",
infisical-dev-api              |               "message": "Invalid uuid",
infisical-dev-api              |               "path": [
infisical-dev-api              |                 "id"
infisical-dev-api              |               ]
infisical-dev-api              |             }
infisical-dev-api              |           ]
infisical-dev-api              |               at get error [as error] (/app/node_modules/zod/lib/types.js:43:31)
infisical-dev-api              |               at ZodObject.parse (/app/node_modules/zod/lib/types.js:143:22)
infisical-dev-api              |               at /app/src/server/plugins/fastify-zod.ts:2:2890
infisical-dev-api              |               at validateParam (/app/node_modules/fastify/lib/validation.js:110:36)
infisical-dev-api              |               at validate (/app/node_modules/fastify/lib/validation.js:132:20)
infisical-dev-api              |               at preValidationCallback (/app/node_modules/fastify/lib/handleRequest.js:91:25)
infisical-dev-api              |               at handler (/app/node_modules/fastify/lib/handleRequest.js:75:7)
infisical-dev-api              |               at handleRequest (/app/node_modules/fastify/lib/handleRequest.js:24:5)
infisical-dev-api              |               at runPreParsing (/app/node_modules/fastify/lib/route.js:609:5)
infisical-dev-api              |               at next (/app/node_modules/fastify/lib/hooks.js:233:9)
infisical-dev-api              |       "aggregateErrors": [
infisical-dev-api              |         {
infisical-dev-api              |           "type": "Object",
infisical-dev-api              |           "message": "Invalid uuid",
infisical-dev-api              |           "stack":
infisical-dev-api              |               
infisical-dev-api              |           "validation": "uuid",
infisical-dev-api              |           "code": "invalid_string",
infisical-dev-api              |           "path": [
infisical-dev-api              |             "id"
infisical-dev-api              |           ]
infisical-dev-api              |         }
infisical-dev-api              |       ],
infisical-dev-api              |       "issues": [
infisical-dev-api              |         {
infisical-dev-api              |           "validation": "uuid",
infisical-dev-api              |           "code": "invalid_string",
infisical-dev-api              |           "message": "Invalid uuid",
infisical-dev-api              |           "path": [
infisical-dev-api              |             "id"
infisical-dev-api              |           ]
infisical-dev-api              |         }
infisical-dev-api              |       ],
infisical-dev-api              |       "name": "ZodError",
infisical-dev-api              |       "statusCode": 400,
infisical-dev-api              |       "code": "FST_ERR_VALIDATION",
infisical-dev-api              |       "validationContext": "params"
infisical-dev-api              |     }

Side note, i think it will be better if the error is more specific. Because is the secret really not found or did it actually expire? As a user, if it is expired, i can tell the sender to resend it but if it is not found then i would think they gave me the wrong link

Copy link
Collaborator

@maidul98 maidul98 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some comments. I think the UI need some fix up. @vmatsiiako will help with it.

Small nit, i would rename the page URL from /shared/secret/ to /share-secret

@ShubhamPalriwala
Copy link
Contributor Author

Side note, i think it will be better if the error is more specific. Because is the secret really not found or did it actually expire? As a user, if it is expired, i can tell the sender to resend it but if it is not found then i would think they gave me the wrong link

We actually had it initially but then from a security + brute force concern, we limited this to treat invalid secrets the same way as expired secrets so that one cannot try decoding it by brute forcing it. And the current setup deletes the secrets once they're expired on views and at 0 GMT when time bound expires so we technically do not store expired secrets as such.

@ShubhamPalriwala
Copy link
Contributor Author

About the undefined error, I was not able to reproduce it :/ Can you try once now with the latest commit to see if you still see it? PS: @vmatsiiako will take a look at the UI side of this PR sometime tomorrow.

Ready for review again 🙏🏼

Comment on lines 8 to 9
t.uuid("orgId").nullable().alter();
t.uuid("userId").nullable().alter();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should be adding hasColumn checks for these ones?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not do that initially because the orgId will always be there since its a part of the initial schema, so I'm not sure if a case for this could be possible. But I'll add it now.

Comment on lines 17 to 18
t.uuid("orgId").notNullable().alter();
t.uuid("userId").notNullable().alter();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here as well

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adding

iv,
tag,
hashedHex,
expiresAt: new Date(expiresAt),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should be validating the value of the expiresAt being passed to this endpoint so that no malicious user could fill up our records with non-expiring secrets (like they set it to 10 years from now or something)

or are we already doing that?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, limiting it to 30 days for now.

Copy link
Collaborator

@maidul98 maidul98 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Somewhere, we keep making these requests, we should catch and avoid these requests when the param is undefined:
{"reqId":"req-13","severity":"INFO","req":{"method":"GET","url":"/api/v1/secret-sharing/public/undefined?hashedHex=","hostname":"localhost:8080","remoteAddress":"192.168.144.1","remotePort":50246}}
  • The text area needs some work, you can only click on a specific area. We should also show the scroll bar if we haven't yet because for long shares, people may not know. Also i don't remember, did we set a max context limit that can be shared?

  • Not sure where the share your own secret button went, it was there but now i don't see it anymore

@ShubhamPalriwala
Copy link
Contributor Author

ShubhamPalriwala commented Jun 7, 2024

Somewhere, we keep making these requests, we should catch and avoid these requests when the param is undefined:
{"reqId":"req-13","severity":"INFO","req":{"method":"GET","url":"/api/v1/secret-sharing/public/undefined?hashedHex=","hostname":"localhost:8080","remoteAddress":"192.168.144.1","remotePort":50246}}

Done

The text area needs some work, you can only click on a specific area. We should also show the scroll bar if we haven't yet because for long shares, people may not know. Also i don't remember, did we set a max context limit that can be shared?

  • Tried debugging Text area issue but couldn't make aby significant progress
  • I think Mac prevents showing scrollbars as default unless scrolled, but apart from that I could nit find a straightforward tailwind class to help us achieve that.
  • We've set max content limit to 10k characters, but that's only on client side. A user can still hit us with a huge payload with the API call directly. Should we limit this? And by how much?

Not sure where the share your own secret button went, it was there but now i don't see it anymore

It's now of the outline variant and available as shown below:

Screenshot 2024-06-08 at 1 17 22 AM Screenshot 2024-06-08 at 1 17 55 AM Screenshot 2024-06-08 at 1 18 12 AM

@ShubhamPalriwala ShubhamPalriwala force-pushed the shubham/eng-984-make-secret-sharing-public-even-for-non-infisical-users branch from aa69f5b to f6e4446 Compare June 10, 2024 02:35
@maidul98 maidul98 merged commit c9f7f64 into main Jun 14, 2024
6 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants