Tell me more ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

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..

Background Information

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 Problem

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.

Server-side considerations

CouchDB on Cloudant

Client-side considerations

The Javascript running on the client requires a URL string to the file. The files that are being referenced are KML layers for Google Maps. A new KML layer is created using this constructor.

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:

that will allow a third party client (not a javascript client, but something automated) to access the first version, by means of some back and forth process. Sort of like how bit.ly works. Does that sound correct? If you don't know how bit.ly works, say so, by all means.

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!

share|improve this question
1  
Welcome to the site, however, this question is really about programming architecture concepts, and not at all about databases. With that in mind, this question needs to be migrated to one of our other expert objective-answers sites. Before we do, I want to help you clean this up some, because to be honest, we're not sure where to get you the most help. So to that end, I'm closing this question as not a real question, but you should be able to comment down here to communicate with me, and you should be able to edit your own question. With that in mind, let me edit your question. – jcolebrand May 21 '12 at 15:15
Wait, you need the javascript to pass a KML URL but you don't want the client (end user's computer) to be able to see the URL because of an embedded username/password? Good luck with that. Can't be done. If you could arrange with the googlemaps API to have it refetch after pulling the first URL, but it's going to have to come back to the client for this to work. Anyways, I'm fairly confident this is a Stack Overflow Q, so I'm going to migrate. – jcolebrand May 22 '12 at 20:37

closed as off topic by jcolebrand May 22 '12 at 20:37

Questions on Database Administrators Stack Exchange are expected to relate to database administration within the scope defined in the FAQ. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about closed questions here.

Browse other questions tagged or ask your own question.