Giter VIP home page Giter VIP logo

security-api-gateway's Introduction

EdgeX Foundry Security Services Implemented with Go

license

Go implementation of EdgeX security services. The security service will need KONG ( https://konghq.com/) and Vault (https://www.vaultproject.io/) to be started first. Make sure they are running and the edgexsecurity will check their status.

Features

  • Reverse proxy for the existing edgex microservices
  • Account creation & JWT authentication for existing services

Run the Security Service with Docker

The repo includes a Dockerfile to dockerize the security service. A docker-compose-proxy.yml file is provided under Docker folder as well to make sure the security service is working with other existing services. They need to be ran in order from the top to bottom.

Build an image of the security service

go get github.com/edgexfoundry/edgexsecurity
cd edgexsecurity
.\build.bat # on Windows
./build.sh # on Linux/Mac
Docker build -t edgex/proxy .

Run the security service

docker run -v vault-config:/vault/config --network=edgex-network edgex/proxy

Notice here vault-config is the name of the volume that keeps the root_token for Vault service, which can be checked with

docker volume ls
docker volume inspect <volume_name>

And edgex-network is the name of the private network that edgex containers create, which can be check with

docker network ls
docker network inspect <network_name>

Other options for security service, E,g, reset the proxy to initial status, create account, delete account

docker run --network=edgex-network edgex/proxy -h
docker run --network=edgex-network edgex/proxy --reset=true
docker run --network=edgex-network edgex/proxy --useradd=<account>
docker run --network=edgex-network edgex/proxy --userdel=<account>

Access existing microservice APIs like ping service of command microservice

use JWT as query string 
curl -k -v -H "host: edgex" https://kong-container:8443/command/api/v1/ping?jwt= <JWT from account creation>
or use JWT in HEADER
curl -k -v -H "host: edgex" https://kong-container:8443/command/api/v1/ping -H "Authorization: Bearer <JWT from account creation>"

Build, Install and Deploy with source files

  1. Make sure KONG is up and running. To start KONG with docker-compose file under Docker/ folder, run commands below
docker-compse -f docker-compose-proxy.yml up -d kong-db
docker-compse -f docker-compose-proxy.yml up -d kong-migrations
docker-compse -f docker-compose-proxy.yml up -d kong
  1. Make sure Vault is up and running. It can be done in a similar way with docker-compose file
docker-compse -f docker-compose-proxy.yml up -d vault
docker-compse -f docker-compose-proxy.yml up -d vault-init-unseal
  1. Build edgexsecurity service with the command below
go get github.com/edgexfoundry/edgexsecurity
cd edgexsecurity/core
go build -o edgexsecurity
  1. Create res folder in the same folder as executable and copy configuration.toml
  2. create a vault seed file by running command below, where path-to-res is the path to res folder that is created in step 4
Docker cp <vault-container-id>:/vault/config/resp-init.json <path-to-res>/
  1. Modify the parameters in the configuration.toml file. Make sure the information for the KONG service, Vault service and Edgex microservices are correct
  2. Run the edgexsecurity service with the command below
./edgexsecurity init=true
  1. Use command below for more options
./edgexsecurity -h

Usage

# initialize reverse proxy 
./edgexsecurity init=true

# reset reverse proxy
./edgexsecurity reset=true

# create account and return JWT for the account 
./edgexsecurity userddd=guest

# delete account
./edgexsecurity userdel=guest

Access exisitng microservices APIs like ping service of command microservice

use JWT as query string 
curl -k -v -H "host: edgex" https://kong-ip:8443/command/api/v1/ping?jwt= <JWT from account creation>
or use JWT in HEADER
curl -k -v -H "host: edgex" https://kong-ip:8443/command/api/v1/ping -H "Authorization: Bearer <JWT from account creation>"

Community

License

Apache-2.0

security-api-gateway's People

Contributors

jpwku avatar tingyuz avatar

Watchers

 avatar James Cloos 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.