Giter Site home page Giter Site logo

zotoio / sls-lambda-opa Goto Github PK

View Code? Open in Web Editor NEW
52.0 2.0 8.0 11 KB

Experimental AWS ApiGateway Authorizer Go Lambda with embedded Open Policy Agent

License: MIT License

Makefile 3.16% Go 93.72% Shell 3.12%
lambda go opa open-policy-agent serverless-framework authorizer golang

sls-lambda-opa's Introduction

sls-lambda-opa

Experiment embedding Open Policy Agent (https://www.openpolicyagent.org/) within a GoLang Api Gateway Authorizer Lambda function, deployed via Serverless framework. See this for info on AWS Api Gateway Authorizer Lambdas: https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-use-lambda-authorizer.html

Install

  1. go https://golang.org/doc/install#install
  2. dep https://github.com/golang/dep
  3. serverless.com framework and configure for aws lambda https://serverless.com/framework/docs/providers/aws/guide/installation/
  4. Pull this repo and chmod 755 *.sh

Deploy

./slsDeploy.sh

This will compile the go files, and then deploy 3 Lambdas and associated API gateway.

  • opacheck (the authorizer)
  • gold target (accessible to gold role only (?role=gold)
  • silver target (accessible to silver and gold roles)

Test

Tail logs as below in one shell, and then use some of the following:

curl -H Authorization:allow https://[apiId].execute-api.ap-southeast-2.amazonaws.com/dev/gold?role=gold
curl -H Authorization:allow https://[apiId].execute-api.ap-southeast-2.amazonaws.com/dev/silver?role=gold
curl -H Authorization:allow https://[apiId].execute-api.ap-southeast-2.amazonaws.com/dev/gold?role=silver

The OPA policy in summary is:

  • deny by default
  • role 'gold' can access /silver and /gold
  • role 'silver' can access /silver but not /gold
  • other roles cannot access either

Tail logs

./slsLogs opacheck

sls-lambda-opa's People

Contributors

wyvern8 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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