Question

I've been playing around with AirBnb's Rendr using the app template they provided on GitHub.

In their example they connect to a RESTful API using HTTP Basic Auth. However in their code they provide the credentials for authentication directly on server startup like so:

$ BASIC_AUTH=githubusername:githubpassword grunt server

Now I'm asking myself if and how I can make this more dynamic, i.e. using the credentials a user has provided on the login of my client application or even use a different authentication schema, like OAuth for example?

Is this possible? Can someone provide an example?

Was it helpful?

Solution

To use the app template as described you first have to implement session management look at this example and customize the authentication schema (basic auth) used to interact with the restful-api provided in the data-adapter file.

rendr-app-template/server/lib/data_adapter.js.

basicAuth = process.env.BASIC_AUTH;
if (basicAuth != null) {
authParts = basicAuth.split(':');
 api.auth = {
   username: authParts[0],
   password: authParts[1],
   sendImmediately: true
 };
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top