tt_goji_oauth

package module
v0.0.0-...-f52735e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 3, 2020 License: MIT Imports: 6 Imported by: 0

README

tt_goji_oauth

Add login with OAUTH to your Goji webapp.

Build Status GoDoc

Currently supports github, but additional OAUTH providers can be plugged in.

Code state

I'm using this with http://apinalytics.tanktop.tv and http://betterrecommendations.com. In the Better Recommendations case I've created a Shopify OAUTH plugin.

How to use

See the example code in /example for full details, but the basics are as follows.

  1. Create a SessionHolder from https://github.com/philpearl/tt_goji_middleware/base, and add session middleware to your mux.
  2. Call tt_goji_oauth.Build() and add the handler it returns to your mux. We suggest you add it at /login/oauth.
  3. Add pages that have logged-in users to your mux beneath the session middleware.
  4. To login, POST to /login/oauth/start/github/. Add a 'next' parameter to control where the user is redirected to after login
  5. When login completes the callback you registered calling tt_goji_oauth.Build() will be called with user information. You should check the user against your database at this point, and set up information in the session.
  6. The user will be redirected to /, or where-ever you specified via the next parameter.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Build

func Build(baseUrl, prefix string, sessionHolder mbase.SessionHolder, callbacks base.Callbacks, provs ...func(baseUrl string) providers.Provider) (*web.Mux, *views.Views)

Build a mux to handle the endpoints required for oauth.

baseUrl   - the full URL to the point where the oauth views are added,
            including trailing /
prefix    - path prefix for the oauth views without trailing /
sessionHolder - the session store used with th tt_goji_middleware session middleware
callbacks - callbacks from tt_goji_oauth to application code
providers - providers to include in the store.

For example "http://localhost:7778/login/oauth/", "/login/oauth". As you can tell we only have two parameters because I've been too lazy to parse the url

This function assumes that the session middleware from [tt_goji_middleware](https://github.com/philpearl/tt_goji_middleware) is in the stack.

Types

This section is empty.

Directories

Path Synopsis
Package base contains interface and struct definitions used by the rest of the code.
Package base contains interface and struct definitions used by the rest of the code.
Package providers contains definitions for OAUTH services.
Package providers contains definitions for OAUTH services.
View functions for OAUTH
View functions for OAUTH

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL