Skip to content

A simple example application which uses the greathouse-openresty boilerplate.

License

Notifications You must be signed in to change notification settings

jesse-greathouse/demotivational

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Demotivational

A simple demonstration of how to integrate google and facebook Oauth2 login functionality.

How to Install

  • Download the git repository
  • git clone https://github.com/jesse-greathouse/demotivational
  • Change to the demotivational directory
  • cd demotivational

Docker Installation

  • The easiest way to run the application is with Docker. If you don't have Docker installed You will need to install docker on your host. Check the Official Docker Site on how to install Docker on your host.
  • Run the configuration script
    • bin/configure-docker.sh
      • The configuration script is interactive.
      • Leave the options blank if you don't want to change them Interactive configuration
      • For this demonstration, I have created defaults for the google and facebook key strings, if you leave them blank, they will revert to safe defaults. leave things blank to accept the default
      • Once you have the proper configuration, press Y to accept
  • Run the "run" script
    • bin/run-docker.sh
  • check http://localhost:3000/
    • You may have changed the designated port during configuration. If that's the case, use the port you specified.

Don't want to use Docker?

Alternatively there are scripts to install the application, directly, on OSX or Linux brands.

  • Check the bin/ folder for an installation script on your platform
  • e.g.: bin/install-osx.sh

Using the application

Login

When you first load the application in your web browser, it will redirect you to the /login screen because you do not yet have a session token. login screen

When you select a provider a pop-up window will direct you to login at the provider of your choice.

  • Please disable pop-up blockers for the purpose of this demonstration

Main Screen

Once you have logged in, the application will redirect you to the home page. A search will be conducted in the Google API, and a random demotivational image will be selected just for you! demotivational image

Logout

When you press the logout button, you will be taken to the logout screen. Not much can be said about this. It will simply destroy your session and redirect you to the login page. logout

The Code

Openresty

  • The application uses a framework called Openresty.
  • It puts Nginx together with LuaJIT to allow powerful Lua scripting from directly inside the Nginx workers.
  • You can see from the source code of this file that this enables Lua scripting in the Nginx configuration.
  • Lua code in the Nginx configuration

The Views

The Models

  • When the application receives authentication information, about the user and the user's token, it creates models of those domain objects, and saves them to the session.
  • Because there are two available authentication providers, the application also uses adapters to conform the provider's domain models to its native domain models.

The Templates

  • The application uses a templating library made by Bungle
  • The template files can be found under the web/ folder. There is a layout, and a simple content template for every view. It's fairly standard just like other templating engines.

The UI

  • The UI uses standard jQuery and Bootstrap assets. I chose these UI tools because they can be accessed by a CDN and they aren't demanding in terms of setup.
  • I have also included the standard JavaScript SDK's for Google and Facebook Oauth2.
  • The JavaScript code that I used to handle this functionality was very boilerplate, taken directly from the docs of the respective SDKs.
  • The method of Authentication is all on the front end. Once the front-end receives authentication information from the provider, the application signals that information to the back-end with xhr calls to the handler endpoints.
  • UI authentication handling

About

A simple example application which uses the greathouse-openresty boilerplate.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published