Sorry for not being clear, I will elaborate all the points here in this edit. Also I had to take out some URLs provided by jcolebrand because of new user spam prevention -_- really StackExchange? its 2012..
I have a CouchDB server that is accessed by another server running PHP (proxy). My web app makes a request for a file to the proxy server. The PHP server sends requests to the CouchDB server with the access credentials (username:password). The CouchDB server returns JSON objects that correspond to matched files. The response includes some meta data about the file and a URL to the file on the CouchDB server. The actual file data itself is not included in the response.
The URL to the document attachment included in the JSON response from CouchDB server includes access credentials (username:password). The proxy server responds to the client side request by returning those JSON objects with the access credentials to the CouchDB server. Currently all data contained within the CouchDB server resides in one database instance. If the client has access to the username:password to the CouchDB then all data could be queried with those access credentials.
CouchDB on Cloudant
What I am looking for
I just need a point in the right direction, no code. I am not sure if this problem can be solved by CouchDB or some type of URL juggling on the PHP proxy. Would I have to save the file in a new location to provide a "safe" URL to the client without the CouchDB credentials? Can CouchDB provide some type of temporary public view or safe way to publicly access the file with a session key? Essentially my solution would come if I can provide a link to a CouchDB document attachment without giving the username/password.
Using CouchDB for a GIS web app, it uses Google Maps API v3. I have some documents in CouchDB that represent map layers, these documents also have attachments with a KML file.
Google Maps API v3 has this method for adding KML layers, it only accepts a URL string as a parameter.
Getting this URL to the actual KML attachment is no problem from PHP but that would expose the API key and password to the client.
Once I have the the URL to the KML on the server would it be possible to create a temporary URL pointing to the fully qualified couchDB URL that I can send to the client?
Edits by jcolebrand:
So it looks like what you need is a way to convert a url of the form:
to something of the format:
If that's the case, and you need to know an architecture pattern, edit this to signify as such.
If you're trying to figure out how to configure CouchDB, because you believe CouchDB can do this natively, feel free to edit in that direction.
The problem right now is that several reasonably advanced programmers can't determine what your problem actually is.
To that end, I want you to consider phrasing your question with three questions:
What am I trying to solve? What have I read that seems to allow me to solve this/ what solutions have I seen that already do what I want? What am I looking for in response? (code, design direction, architecture drawings, etc?)
And with those three, we should be able to help a little better. We get that you're doing something with CouchDB, but you could just omit that with "trying not to let the end-user see the server-side password" and eliminate CouchDB from the equation. Same goes for GoogleMaps API v3, because you're only interested (in the way that I can tell) for the URL itself. You can generate the Maps URL, that's not an issue. So don't clutter the question with it.
Hopefully this all makes sense. Let me know how I can help!