try5

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: May 22, 2015 License: MIT Imports: 1 Imported by: 0

README

TRY5

Version: v0.0.2

Try5 is a new intent to develop an easy and basic authentication system. The functionalyty is exposed through REST Web Services.

It is an opinionated library with absolutely no garanties. Use at your own risk.

You need:

  • Go v1.4.2
  • PostgreSQL database v9.4 (optional)
  • Not much really...

Proposed features:

  • HMAC Authentication
  • JWT Authentication
  • Plain user / password authentication
  • User management
  • Key/Token managemnt
  • RBAC Authorization
  • REST endpoint
  • RPC endpoint

Getting Started

Install
go get github.com/jllopis/try5

Specification

The server expect to receive the data in the body of the request for POST and PUT verbs using type application/json; charset=UTF-8. The data provided as url vars or via application/x-www-form-urlencoded will not be accepted.

  • GET request to /api/v1/accounts

    $ curl -ki https://b2d:9000/api/v1/accounts
    HTTP/1.1 200 OK
    Content-Type: application/json; charset=UTF-8
    Date: Fri, 22 May 2015 11:23:57 GMT
    Content-Length: 715
    
    [
      {
        "uid": "447fb74b-114c-46c9-aee4-292998d845bb",
        "email": "tu5@test.com",
        "name": "test user 5",
        "password": "$2a$10$h.tOLA00ZLKux5IWa6l4JOcxpa2SdCTS56w2p7I31JZw2lZM3ivIK",
        "active": true,
        "gravatar": null,
        "created": "2015-05-22T11:15:05.840968723Z",
        "updated": "2015-05-22T11:15:05.840968723Z",
        "deleted": null
      },
      {
        "uid": "60b51e16-fe83-4ac2-853c-7cbc1f250a09",
        "email": "tu4@test.com",
        "name": "test user 4",
        "password": "$2a$10$KfX8Sf13JsQWSelCxDDFluy0iHMaNmVYzGrZTHux3NYKS7476Qp0y",
        "active": true,
        "gravatar": null,
        "created": "2015-05-22T11:22:32.145080999Z",
        "updated": "2015-05-22T11:22:32.145080999Z",
        "deleted": null
      }
    ]
    
  • GET request to /api/v1/accounts/7ecee355-537b-492c-ab23-6a41219959d1

    $ curl -ki https://b2d:9000/api/v1/accounts/7ecee355-537b-492c-ab23-6a41219959d1
    HTTP/1.1 200 OK
    Content-Type: application/json; charset=UTF-8
    Date: Fri, 22 May 2015 10:57:40 GMT
    Content-Length: 359
    
    [
      {
        "uid": "7ecee355-537b-492c-ab23-6a41219959d1",
        "email": "tu5@test.com",
        "name": "test user 5",
        "password": "$2a$10$651aQ.FoQQo3t2BBhI3WX.rVSKbPu4ks8feMG1zi5dBvysraY7nYm",
        "active": true,
        "gravatar": null,
        "created": "2015-05-22T10:01:56.160527217Z",
        "updated": "2015-05-22T10:01:56.160527217Z",
        "deleted": null
      }
    ]
    
  • POST request to /api/v1/accounts

    $ curl -ki https://b2d:9000/api/v1/accounts -X POST -d '{"email":"tu4@test.com","name":"test user 4","password":"1234","active":true}'
    HTTP/1.1 200 OK
    Content-Type: application/json; charset=UTF-8
    Date: Fri, 22 May 2015 11:22:32 GMT
    Content-Length: 333
    
    {
      "uid": "60b51e16-fe83-4ac2-853c-7cbc1f250a09",
      "email": "tu4@test.com",
      "name": "test user 4",
      "password": "$2a$10$KfX8Sf13JsQWSelCxDDFluy0iHMaNmVYzGrZTHux3NYKS7476Qp0y",
      "active": true,
      "gravatar": null,
      "created": "2015-05-22T11:22:32.145080999Z",
      "updated": "2015-05-22T11:22:32.145080999Z",
      "deleted": null
    }
    
  • PUT request to /api/v1/accounts/

    $ curl -ki https://b2d:9000/api/v1/accounts/e557e74a-cb35-4039-b4e5-f9c6ca777c5b -X PUT -d '{"name": "Test User 4","email":"newtu4@test4.com","password":"1234","active":true}'
    HTTP/1.1 200 OK
    Content-Type: application/json; charset=UTF-8
    Date: Fri, 22 May 2015 11:48:41 GMT
    Content-Length: 309
    
    {
      "uid": "e557e74a-cb35-4039-b4e5-f9c6ca777c5b",
      "email": "newtu4@test4.com",
      "name": "Test User 4",
      "password": "$2a$10$MWCvQXeCw0D1jXYQUMGCJuAFsTPzTvuYYVE2/1pEhu/.LQHqmqsPu",
      "active": true,
      "gravatar": null,
      "created": "2015-05-22T11:22:32.145080999Z",
      "updated": "2015-05-22T11:48:41.567466863Z",
      "deleted": null
    }
    
  • DELETE request to /api/v1/accounts/802aa9ef-b00e-4204-9b75-4dbb82d20643

    $ curl -ki https://localhost:9000/api/v1/accounts/802aa9ef-b00e-4204-9b75-4dbb82d20643 -X DELETE
    HTTP/1.1 200 OK
    Content-Type: application/json; charset=UTF-8
    Date: Fri, 22 May 2015 15:56:49 GMT
    Content-Length: 164
    
    {
      "status": "ok",
      "action": "delete",
      "info": "802aa9ef-b00e-4204-9b75-4dbb82d20643",
      "table": "accounts",
      "id": "802aa9ef-b00e-4204-9b75-4dbb82d20643"
    }
    
  • POST request to /api/v1/authenticate

    $ curl -ki https://localhost:9000/api/v1/authenticate -X POST -d "email=tu14@test14.com" -d "password=12345"
    HTTP/1.1 200 OK
    Content-Type: application/json; charset=UTF-8
    Date: Fri, 22 May 2015 16:47:47 GMT
    Content-Length: 334
    
    {
      "account": {
        "uid": "eccd8c58-38ec-4385-9569-6eb26a83fa17",
        "email": "tu14@test14.com",
        "name": "Test User 14",
        "password": null,
        "active": true,
        "gravatar": null,
        "created": "2015-05-22T15:04:45.710780544Z",
        "updated": "2015-05-22T15:46:18.597248475Z",
        "deleted": null
      },
      "status": "ok"
    }
    

Status Codes

The server returns the following status codes:

  • 200: Ok
  • 201: Created
  • 400: Bad Request
  • 403: Forbidden
  • 404: Not Found
  • 500: Internal Server Error (dont know what happened)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Try5

type Try5 struct {
	store.Storer
}

func New

func New(s store.Storer) *Try5

New initialize the storage with a compliant database and return a Try5 struct to work with

Directories

Path Synopsis
Godeps
_workspace/src/bitbucket.org/jllopis/getconf
Package getconf load the variables to be used in a program from different sources: 1.
Package getconf load the variables to be used in a program from different sources: 1.
_workspace/src/code.google.com/p/go-uuid/uuid
The uuid package generates and inspects UUIDs.
The uuid package generates and inspects UUIDs.
_workspace/src/github.com/boltdb/bolt
Package bolt implements a low-level key/value store in pure Go.
Package bolt implements a low-level key/value store in pure Go.
_workspace/src/github.com/fvbock/endless
endless provides a drop in replacement for the `net/http` stl functions `ListenAndServe` and `ListenAndServeTLS` to achieve zero downtime restarts and code upgrades.
endless provides a drop in replacement for the `net/http` stl functions `ListenAndServe` and `ListenAndServeTLS` to achieve zero downtime restarts and code upgrades.
_workspace/src/github.com/gorilla/securecookie
Package gorilla/securecookie encodes and decodes authenticated and optionally encrypted cookie values.
Package gorilla/securecookie encodes and decodes authenticated and optionally encrypted cookie values.
_workspace/src/github.com/jllopis/aloja/mw
Package original source: https://github.com/gorilla/handlers
Package original source: https://github.com/gorilla/handlers
_workspace/src/github.com/jmoiron/sqlx
Package sqlx provides general purpose extensions to database/sql.
Package sqlx provides general purpose extensions to database/sql.
_workspace/src/github.com/jmoiron/sqlx/reflectx
Package reflect implements extensions to the standard reflect lib suitable for implementing marshaling and unmarshaling packages.
Package reflect implements extensions to the standard reflect lib suitable for implementing marshaling and unmarshaling packages.
_workspace/src/github.com/justinas/alice
Package alice provides a convenient way to chain http handlers.
Package alice provides a convenient way to chain http handlers.
_workspace/src/github.com/lib/pq
Package pq is a pure Go Postgres driver for the database/sql package.
Package pq is a pure Go Postgres driver for the database/sql package.
_workspace/src/github.com/lib/pq/listen_example
Below you will find a self-contained Go program which uses the LISTEN / NOTIFY mechanism to avoid polling the database while waiting for more work to arrive.
Below you will find a self-contained Go program which uses the LISTEN / NOTIFY mechanism to avoid polling the database while waiting for more work to arrive.
_workspace/src/github.com/lib/pq/oid
Package oid contains OID constants as defined by the Postgres server.
Package oid contains OID constants as defined by the Postgres server.
_workspace/src/github.com/mattn/go-isatty
Package isatty implements interface to isatty
Package isatty implements interface to isatty
_workspace/src/github.com/mgutz/ansi
Package ansi is a small, fast library to create ANSI colored strings and codes.
Package ansi is a small, fast library to create ANSI colored strings and codes.
_workspace/src/github.com/mgutz/str
Package str is a comprehensive set of string functions to build more Go awesomeness.
Package str is a comprehensive set of string functions to build more Go awesomeness.
_workspace/src/github.com/rs/cors
Package cors is net/http handler to handle CORS related requests as defined by http://www.w3.org/TR/cors/ You can configure it by passing an option struct to cors.New: c := cors.New(cors.Options{ AllowedOrigins: []string{"foo.com"}, AllowedMethods: []string{"GET", "POST", "DELETE"}, AllowCredentials: true, }) Then insert the handler in the chain: handler = c.Handler(handler) See Options documentation for more options.
Package cors is net/http handler to handle CORS related requests as defined by http://www.w3.org/TR/cors/ You can configure it by passing an option struct to cors.New: c := cors.New(cors.Options{ AllowedOrigins: []string{"foo.com"}, AllowedMethods: []string{"GET", "POST", "DELETE"}, AllowCredentials: true, }) Then insert the handler in the chain: handler = c.Handler(handler) See Options documentation for more options.
_workspace/src/github.com/spf13/cobra
Package cobra is a commander providing a simple interface to create powerful modern CLI interfaces.
Package cobra is a commander providing a simple interface to create powerful modern CLI interfaces.
_workspace/src/github.com/spf13/pflag
pflag is a drop-in replacement for Go's flag package, implementing POSIX/GNU-style --flags.
pflag is a drop-in replacement for Go's flag package, implementing POSIX/GNU-style --flags.
_workspace/src/github.com/unrolled/render
Package render is a package that provides functionality for easily rendering JSON, XML, binary data, and HTML templates.
Package render is a package that provides functionality for easily rendering JSON, XML, binary data, and HTML templates.
_workspace/src/golang.org/x/crypto/bcrypt
Package bcrypt implements Provos and Mazières's bcrypt adaptive hashing algorithm.
Package bcrypt implements Provos and Mazières's bcrypt adaptive hashing algorithm.
_workspace/src/golang.org/x/crypto/blowfish
Package blowfish implements Bruce Schneier's Blowfish encryption algorithm.
Package blowfish implements Bruce Schneier's Blowfish encryption algorithm.
cmd

Jump to

Keyboard shortcuts

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