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

How are you supposed to obfuscate the key in the Swift client? #40

Open
bnhoang2k opened this issue Sep 20, 2024 · 5 comments
Open

How are you supposed to obfuscate the key in the Swift client? #40

bnhoang2k opened this issue Sep 20, 2024 · 5 comments

Comments

@bnhoang2k
Copy link

In the README, you make a node, then use that node to create a config, then finally use that config to create a client. However, you can't even make the config without an apiKey; is there a way to get this key without embedding it in the source code?

It seems weird that you need the client to make an api key; but in order to make a client, you need an API key first!

Typesense Version: v1.0.0

@jasonbosco
Copy link
Member

On Typesense Cloud, you can generate an API key in the UI to use in the client. When self-hosting, you want to use the bootstrap API key in the client or in curl requests, to generate subsequent keys.

@bnhoang2k
Copy link
Author

bnhoang2k commented Sep 21, 2024

That was the thing I was afraid of. I was trying to find a way to not embed the bootstrap key (or any key for that matter) into the source code of my iOS application to create other keys. I wanted to hide it.

Is there really no way around this?

@jasonbosco
Copy link
Member

jasonbosco commented Sep 21, 2024

You would run the Typesense server on a remote server, start it with the bootstrap API key of your choice on that server. Then on the server, use the bootstrap API key with curl and the /keys API endpoint and generate a search api key and only use that generated api key in your client libraries.

That way you’re not exposing the bootstrap api key on the client side.

@bnhoang2k
Copy link
Author

So what I'm hearing is make search api key, then embed that into my code? There's no way to hide it?

@jasonbosco
Copy link
Member

For a mobile app, you want to have an API endpoint on your backend, with authenticates a user and then generates a short-lived restricted API key for that user and passes it to the app on login. That way the API key is not embedded inside your app, instead it's ephemeral and only stored in memory.

You can periodically rotate the key as needed in your backend, and invalidate the old one.

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

No branches or pull requests

2 participants