harunnryd / gateid by harunnryd

API gateway written in PHP7 and Lumen.
0
5
2
Package Data
Maintainer Username: harunnryd
Package Create Date: 2018-07-27
Package Last Update: 2018-07-28
Language: PHP
License: MIT
Last Refreshed: 2024-04-18 15:15:46
Package Statistics
Total Downloads: 0
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 5
Total Watchers: 2
Total Forks: 1
Total Open Issues: 0

Gateid - Lumen API Gateway

Latest Stable Version Total Downloads Latest Unstable Version License

What is an API Gateway?

An API Gateway sits in front of your application(s) and/or services and manages the heavy lifting of authorisation, access control and throughput limiting to your services. Ideally, it should mean that you can focus on creating services instead of implementing management infrastructure. For example, if you have written a really awesome web service that provides geolocation data for all the cats in NYC, and you want to make it public, integrating an API gateway is a faster, more secure route than writing your own authorisation middleware.

Requirements and dependencies

  • PHP >= 7.0
  • Lumen 5.6
  • Guzzle 6
  • Laravel Passport (with Lumen Passport)
  • Spatie Permission (with [Spatie Permission] (https://github.com/spatie/laravel-permission)

How it works!

$ composer install
$ php artisan passport:install
$ vim storage/app/routes.json

if you need to use Oauth2 (Passport) please tag oauth:api on middleware

# example routes.json

{
    "global": {
        "domain": "54.169.181.142:7002"
    },
    "routes": [
        {
            "description": "get specific role",
            "method": "get",
            "middleware": ["auth:api"],
            "path": "/api/v2/roles/{id}",
            "actions": [
                {
                    "method": "get",
                    "hostname": "54.169.181.142:7003",
                    "service": "",
                    "path": "/rbac/v2/roles/{id}",
                    "outputKey": "role"
                }
            ]
        },
        {
            "description": "get all roles",
            "method": "get",
            "middleware": ["auth:api"],
            "path": "/api/v2/roles",
            "actions": [
                {
                    "method": "get",
                    "hostname": "54.169.181.142:7003",
                    "service": "",
                    "path": "/rbac/v2/roles",
                    "outputKey": "roles"
                }
            ]
        },
        {
            "description": "create role",
            "method": "post",
            "middleware": ["auth:api"],
            "path": "/api/v2/roles",
            "actions": [
                {
                    "method": "post",
                    "hostname": "54.169.181.142:7003",
                    "service": "",
                    "path": "/rbac/v2/roles",
                    "outputKey": "role"
                }
            ]
        },
        {
            "description": "update role",
            "method": "patch",
            "middleware": ["auth:api"],
            "path": "/api/v2/roles/{id}",
            "actions": [
                {
                    "method": "patch",
                    "hostname": "54.169.181.142:7003",
                    "service": "",
                    "path": "/rbac/v2/roles/{id}",
                    "outputKey": "role"
                }
            ]
        },
        {
            "description": "delete role",
            "method": "delete",
            "middleware": ["auth:api"],
            "path": "/api/v2/roles/{id}",
            "actions": [
                {
                    "method": "delete",
                    "hostname": "54.169.181.142:7003",
                    "service": "",
                    "path": "/rbac/v2/roles/{id}",
                    "outputKey": "role"
                }
            ]
        },
        {
            "description": "get specific permission",
            "method": "get",
            "middleware": ["auth:api"],
            "path": "/api/v2/permissions/{id}",
            "actions": [
                {
                    "method": "get",
                    "hostname": "54.169.181.142:7003",
                    "service": "",
                    "path": "/rbac/v2/permissions/{id}",
                    "outputKey": "permission"
                }
            ]
        },
        {
            "description": "get all permission",
            "method": "get",
            "middleware": ["auth:api"],
            "path": "/api/v2/permissions",
            "actions": [
                {
                    "method": "get",
                    "hostname": "54.169.181.142:7003",
                    "service": "",
                    "path": "/rbac/v2/permissions",
                    "outputKey": "permissions"
                }
            ]
        },
        {
            "description": "create permission",
            "method": "post",
            "middleware": ["auth:api"],
            "path": "/api/v2/permissions",
            "actions": [
                {
                    "method": "post",
                    "hostname": "54.169.181.142:7003",
                    "service": "",
                    "path": "/rbac/v2/permissions",
                    "outputKey": "permission"
                }
            ]
        },
        {
            "description": "update permission",
            "method": "patch",
            "middleware": ["auth:api"],
            "path": "/api/v2/permissions/{id}",
            "actions": [
                {
                    "method": "patch",
                    "hostname": "54.169.181.142:7003",
                    "service": "",
                    "path": "/rbac/v2/permissions/{id}",
                    "outputKey": "permission"
                }
            ]
        },
        {
            "description": "delete permission",
            "method": "delete",
            "middleware": ["auth:api"],
            "path": "/api/v2/permissions/{id}",
            "actions": [
                {
                    "method": "delete",
                    "hostname": "54.169.181.142:7003",
                    "service": "",
                    "path": "/rbac/v2/permissions/{id}",
                    "outputKey": "permission"
                }
            ]
        },
        {
            "description": "attach role to user",
            "method": "patch",
            "middleware": ["auth:api"],
            "path": "/api/v2/users/{id}/roles",
            "actions": [
                {
                    "method": "patch",
                    "hostname": "54.169.181.142:7003",
                    "service": "",
                    "path": "/rbac/v2/users/{id}/roles",
                    "outputKey": "user"
                }
            ]
        },
        {
            "description": "detach role to user",
            "method": "delete",
            "middleware": ["auth:api"],
            "path": "/api/v2/users/{id}/roles",
            "actions": [
                {
                    "method": "delete",
                    "hostname": "54.169.181.142:7003",
                    "service": "",
                    "path": "/rbac/v2/users/{id}/roles",
                    "outputKey": "user"
                }
            ]
        },
        {
            "description": "attach permission to user",
            "method": "patch",
            "middleware": ["auth:api"],
            "path": "/api/v2/users/{id}/permissions",
            "actions": [
                {
                    "method": "patch",
                    "hostname": "54.169.181.142:7003",
                    "service": "",
                    "path": "/rbac/v2/users/{id}/permissions",
                    "outputKey": "user"
                }
            ]
        },
        {
            "description": "detach permission to user",
            "method": "delete",
            "middleware": ["auth:api"],
            "path": "/api/v2/users/{id}/permissions",
            "actions": [
                {
                    "method": "delete",
                    "hostname": "54.169.181.142:7003",
                    "service": "",
                    "path": "/rbac/v2/users/{id}/permissions",
                    "outputKey": "user"
                }
            ]
        },
        {
            "description": "get all role by user",
            "method": "get",
            "middleware": ["auth:api"],
            "path": "/api/v2/users/{id}/roles",
            "actions": [
                {
                    "sequence": 0,
                    "method": "get",
                    "hostname": "54.169.181.142:7004",
                    "service": "",
                    "path": "/account/v2/users/{id}",
                    "outputKey": "user"
                },
                {
                    "sequence": 0,
                    "method": "get",
                    "hostname": "54.169.181.142:7003",
                    "service": "",
                    "path": "/rbac/v2/users/{id}/roles",
                    "outputKey": "user.roles"
                }
            ]
        },
        {
            "description": "get all permission by role",
            "method": "get",
            "middleware": ["auth:api"],
            "path": "/api/v2/roles/{id}/permissions",
            "actions": [
                {
                    "sequence": 0,
                    "method": "get",
                    "hostname": "54.169.181.142:7003",
                    "service": "",
                    "path": "/rbac/api/v2/roles/{id}",
                    "outputKey": "role"
                },
                {
                    "sequence": 0,
                    "method": "get",
                    "hostname": "54.169.181.142:7003",
                    "service": "",
                    "path": "/rbac/v2/roles/{id}/permissions",
                    "outputKey": "role.permissions"
                }
            ]
        },

        {
            "description": "get all user by role",
            "method": "get",
            "middleware": ["auth:api"],
            "path": "/api/v2/roles/{id}/users",
            "actions": [
                {
                    "sequence": 0,
                    "method": "get",
                    "hostname": "54.169.181.142:7003",
                    "service": "",
                    "path": "/rbac/api/v2/roles/{id}",
                    "outputKey": "role"
                },
                {
                    "sequence": 1,
                    "method": "get",
                    "hostname": "54.169.181.142:7003",
                    "service": "",
                    "path": "/rbac/v2/roles/{id}/users",
                    "outputKey": "role.users"
                }
            ]
        },
        {
            "description": "register user",
            "method": "post",
            "middleware": [],
            "path": "/api/v2/users",
            "actions": [
                {
                    "method": "post",
                    "hostname": "54.169.181.142:7004",
                    "service": "",
                    "path": "/account/v2/users",
                    "outputKey": "user"
                }
            ]
        },
        {
            "description": "delete user",
            "method": "delete",
            "middleware": [],
            "path": "/api/v2/users/{id}",
            "actions": [
                {
                    "method": "delete",
                    "hostname": "54.169.181.142:7004",
                    "service": "",
                    "path": "/account/v2/users/{id}",
                    "outputKey": "user"
                }
            ]
        },
        {
            "description": "update user",
            "method": "patch",
            "middleware": ["auth:api"],
            "path": "/api/v2/users/{id}",
            "actions": [
                {
                    "method": "patch",
                    "hostname": "54.169.181.142:7004",
                    "service": "",
                    "path": "/account/v2/users/{id}",
                    "outputKey": "user"
                }
            ]
        },
        {
            "description": "get user",
            "method": "get",
            "middleware": ["auth:api"],
            "path": "/api/v2/users/{id}",
            "actions": [
                {
                    "sequence": 0,
                    "method": "get",
                    "hostname": "54.169.181.142:7004",
                    "service": "",
                    "path": "/account/v2/users/{id}",
                    "outputKey": "user"                    
                }
            ]
        },
        {
            "description": "get user self",
            "method": "get",
            "middleware": ["auth:api"],
            "path": "/api/v2/self-users",
            "actions": [
                {
                    "sequence": 0,
                    "method": "get",
                    "hostname": "54.169.181.142:7004",
                    "service": "",
                    "path": "/account/v2/self-users",
                    "outputKey": "user"                    
                }
            ]
        },
        {
            "description": "get user",
            "method": "get",
            "middleware": ["auth:api"],
            "path": "/api/v2/users",
            "actions": [
                {
                    "sequence": 0,
                    "method": "get",
                    "hostname": "54.169.181.142:7004",
                    "service": "",
                    "path": "/account/v2/users",
                    "outputKey": "users"                    
                }
            ]
        },
        {
            "description": "get location point",
            "method": "post",
            "middleware": ["auth:api"],
            "path": "/api/v2/location-points",
            "actions": [
                {
                    "sequence": 0,
                    "method": "post",
                    "hostname": "54.169.181.142:7006",
                    "service": "",
                    "path": "/reservation/v2/location-points",
                    "outputKey": "location_points"                    
                }
            ]
        }
    ]
}

Security Vulnerabilities

If you discover a security vulnerability within Gateid, please send an e-mail to harun nur rasyid at harunwols@gmail.com. All security vulnerabilities will be promptly addressed.

License

Gateid is open-sourced software licensed under the MIT license