All Projects → gobuffalo → buffalo-auth

gobuffalo / buffalo-auth

Licence: MIT license
Buffalo auth plugin helps adding username password authentication to your app

Programming Languages

go
31211 projects - #10 most used programming language
HTML
75241 projects
Makefile
30231 projects

Projects that are alternatives of or similar to buffalo-auth

buffalo-heroku
Archived use github.com/gobuffalo/buffalo-heroku
Stars: ✭ 16 (-50%)
Mutual labels:  gobuffalo
tags
HTML tags in Go
Stars: ✭ 50 (+56.25%)
Mutual labels:  gobuffalo
buffalo-goth
Goth Generator for Buffalo
Stars: ✭ 13 (-59.37%)
Mutual labels:  gobuffalo
buffla
URL Shortner written in Buffalo
Stars: ✭ 30 (-6.25%)
Mutual labels:  gobuffalo
buffalo-azure
A gobuffalo plugin for working with Azure.
Stars: ✭ 29 (-9.37%)
Mutual labels:  gobuffalo
Buffalo
Rapid Web Development w/ Go
Stars: ✭ 6,476 (+20137.5%)
Mutual labels:  gobuffalo
Packr
The simple and easy way to embed static files into Go binaries.
Stars: ✭ 3,332 (+10312.5%)
Mutual labels:  gobuffalo
buffalo-heroku
Sets up and deploys apps to Heroku
Stars: ✭ 14 (-56.25%)
Mutual labels:  gobuffalo
suite
A test suite for Buffalo applications
Stars: ✭ 24 (-25%)
Mutual labels:  gobuffalo
flect
An inflection engine for golang
Stars: ✭ 69 (+115.63%)
Mutual labels:  gobuffalo
genny
A framework for writing modular generators
Stars: ✭ 50 (+56.25%)
Mutual labels:  gobuffalo

Auth Generator for Buffalo

Tests Go Reference Go Report Card

Installation

$ buffalo plugins install github.com/gobuffalo/buffalo-auth

Usage

To generate a basic username / password authentication you can run:

$ buffalo generate auth

This will do:

  • Generate User authentication actions in actions/auth.go:

    • AuthNew
    • AuthCreate
    • AuthDestroy
  • Generate User signup actions in actions/users.go:

    • UsersNew
    • UsersCreate
  • Generate User model and migration ( model will be in models/user.go):

  • Generate Auth Middlewares

    • SetCurrentUser
    • Authorize
  • Add actions and middlewares in app.go:

    • [GET] /users/new -> UsersNew
    • [POST] /users -> UsersCreate
    • [GET] /signin -> AuthNew
    • [POST] /signin -> AuthCreate
    • [DELETE] /signout -> AuthDestroy
  • Use middlewares for all your actions and skip

    • HomeHandler
    • UsersNew
    • UsersCreate
    • AuthNew
    • AuthCreate

User model Fields

Sometimes you would want to add extra fields to the user model, to do so, you can pass those to the auth command and use the pop notation for those fields, for example:

$ buffalo generate auth first_name last_name notes:text

Will generate a User model (inside models/user.go) that looks like:

type User struct {
  ID                   uuid.UUID `json:"id" db:"id"`
  CreatedAt            time.Time `json:"created_at" db:"created_at"`
  UpdatedAt            time.Time `json:"updated_at" db:"updated_at"`
  Email                string    `json:"email" db:"email"`
  PasswordHash         string    `json:"password_hash" db:"password_hash"`
  FirstName            string    `json:"first_name" db:"first_name"`
  LastName             string    `json:"last_name" db:"last_name"`
  Notes                string    `json:"notes" db:"notes"`
  Password             string    `json:"-" db:"-"`
  PasswordConfirmation string    `json:"-" db:"-"`
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].