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?

Était-ce utile?

La 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
 };
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top