Giter VIP home page Giter VIP logo

go-simple-api-gateway's Introduction

GO-SIMPLE-API-GATEWAY

status

A simple API gateway written by golang.

Support for authenticate and authorization, and web applications will be protected after the gateway.

in development now.

documents will be wrote later.

ARCH

arch

CONFIGURATION

You could use cli option or environment varibles to config your api gateway

./go-simple-api-gateway --help
Options:

  -h, --help                                display help information
  -c, --*conn[=$GATEWAY_CONN_STR]          *mysql connection str
  -l, --*listen[=$GATEWAY_LS]              *gateway listen host and port
  -r, --*resource[=$GATEWAY_RESOURCE_URL]  *gateway resource url
  • -c --conn GATEWAY_CONN_STR, mysql connection string, format is user:pass@tcp(domain:port)/dbname

  • -l --listen GATEWAY_LS, gateway listen addr, format is host:port, example: 0.0.0.0:1329

  • -r --resource GATEWAY_RESOURCE_URL, gateway protect target, the resource server, could be a api server, format is http://host:port

DOCKER

you could find docker image from here

example:

docker run -d --restart=always -p 11329:1329 -e GATEWAY_CONN_STR='user:pass@tcp(mysql:3306)/db_name' -e GATEWAY_LS=':1329' -e GATEWAY_RESOURCE_URL='http://api:1323' --link mariadb:mysql --link citi_api:api --name citi_gateway theosun/go-simple-api-gateway

DOWNLOAD

You could download the latest build binaries from here

APIs

payload model

use /_/auth/* apis to authenticate, and use /_/gateway/* apis to authorization

authenticate model:

{
  "username":"",
  "password":"",
  "new_password":""
}

policy model:

{
  "user":"",
  "path":"",
  "method":""
}

user is a user or a role name. method can be *


userrole model:

{
  "user":"",
  "role":""
}

api list

[
  {
    "method": "POST",
    "path": "/_/auth/api/updatepassword",
    "name": "Passwrod Update"
  },
  {
    "method": "POST",
    "path": "/_/auth/api/auth",
    "name": "User Auth"
  },
  {
    "method": "POST",
    "path": "/_/auth/api/register",
    "name": "Register New User"
  },
  {
    "method": "DELETE",
    "path": "/_/gateway/api/role/",
    "name": "Remove Role From User"
  },
  {
    "method": "GET",
    "path": "/_/gateway/api/role/users",
    "name": "Get Users of a Role"
  },
  {
    "method": "GET",
    "path": "/_/gateway/api/user/role",
    "name": "Get Roles of a User"
  },
  {
    "method": "GET",
    "path": "/_/gateway/api/policy/",
    "name": "Get All Policies"
  },
  {
    "method": "PUT",
    "path": "/_/gateway/api/role/",
    "name": "Add Role To User"
  },
  {
    "method": "POST",
    "path": "/_/gateway/api/policy/enforce",
    "name": "Find Some Authority"
  },
  {
    "method": "GET",
    "path": "/_/gateway/api/policy/group",
    "name": "Get Group Policies"
  },
  {
    "method": "DELETE",
    "path": "/_/gateway/api/policy/",
    "name": "Remove Authority"
  },
  {
    "method": "PUT",
    "path": "/_/gateway/api/policy/",
    "name": "Add Policy"
  }
]

go-simple-api-gateway's People

Contributors

soontao avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.