Prevent unauthorised access of public endpoints by for example bots or bad clients.

Anonymus API Auth Provider

Inspired by: https://hackernoon.com/improve-the-security-of-api-keys-v5kp3wdu

Architecture

The basic idea is, to prevent unauthorised access of a public endpoint by bots or bad clients. Only known clients should be able to use the api. For example when you have a POST interface which should only be able to be requested by your own website. All requests from other clients to this public POST endpoint should be rejected.

This Repository introduces a separate serive, the "Anonymus API Auth Provider" (aaap), which can be requested to retrieve an access-token. The public endpoint can then validate this token.

The aaap and the public endpoint therefore share an api-key as secret. The aaap signs the token with the api-key and the public endpoint can check if the signature was signed with this api-key. Otherwise the public endpoint would reject the request.

But before the aaap generates the access-token and sends it to the requesting client, the client has to solve a challenge. This challenge is the shared secret between the aaap and the authorised client (e.g. your website):

Authorised Client

A bad client or a bot cannot solve the challenge provided by the aaap. In this case the aaap would send an invalid access-token to the client, and the public endpoint check for the token signature would fail. The request would be rejected:

Bot or Bad Client

An attacker of this public endpoint would have to reverse engineer the authorised client, to find out how the challenge of the aaap can be solved. This comes with an reasonable amount of effort especially when the code of the authorised client is obfuscated.

Usage

Define your own challenge.sh & response.sh and mount them into the docker image.

  • Make sure to provide a randomly unique challenge on every execution of the challenge.sh.
  • Make sure to implement the response.sh to generate a deterministic response on each given input generated by the challenge.sh
    ⚠️ The response must also be implemented on your client.
  • Define an api-key and provide it in the environement variables of the docker image.
  • Define how long the token should be valid
    ⚠️ The token lifetime should be validated in your public endpoint, as well as the token signature.

Docker

Build your own docker image

Integrate your challenge.sh & response.sh directly in your own docker image. It is also advisable to install some more programs, for example to generate uuids which can be used for designing your custom challenge/response.

cd example
# build
docker build -t authprovider-example .
# run
docker run -p 8080:8080 -e API_KEY=your-api-key -e TOKEN_EXPIRE=3600 -e PORT=8080 authprovider-example

Mount volume

You can also mount your custom challenge.sh & response.sh.

# build
docker build -f docker/Dockerfile -t authprovider .
# run
docker run -p 8080:8080 -v `pwd`/path/to/your/own/scripts/folder:/service/scripts -e API_KEY=your-api-key -e TOKEN_EXPIRE=3600 -e PORT=8080 authprovider

Development

API_KEY=your-key go run main.go

Known Limitations

  • clustering currently not possible
    will be possible in the future with redis integration
Similar Resources

Golang Mongodb Jwt Auth Example Using Echo

Golang Mongodb Jwt Auth Example Using Echo

Golang Mongodb Jwt Auth Example Using Echo Golang Mongodb Rest Api Example Using Echo Prerequisites Golang 1.16.x Docker 19.03+ Docker Compose 1.25+ I

Nov 30, 2022

Example App written in Golang for provide AuthZ/N using JWT

RCK Auth Application Example App written in Golang for provide Authentication & Authorization using Json Web Tokens. Run with Docker / Podman Run a Po

Feb 25, 2022

Example of a simple application which is powered by a third-party oAuth 2.0 server for it's authentication / authorization. Written in Golang.

go mod init github.com/bartmika/osin-thirdparty-example go get github.com/spf13/cobra go get github.com/openshift/osin go get github.com/openshift/osi

Jan 4, 2022

golang csrf react example, using gorilla/mux and gorilla/mux

Demo REST backend Gorilla csrf middleware and Js frontend Use gorilla/mux and gorilla/csrf How to run open goland IDE, run middleware_test.go by click

Feb 2, 2022

Prevent unauthorised access of public endpoints by for example bots or bad clients.

Prevent unauthorised access of public endpoints by for example bots or bad clients.

Anonymous API Auth Provider Inspired by: https://hackernoon.com/improve-the-security-of-api-keys-v5kp3wdu Architecture The basic idea is, to prevent u

Nov 28, 2021

🐿️ Revoltgo is a go package for writing bots / self-bots in revolt easily.

Revoltgo Revoltgo is a go package for writing bots / self-bots in revolt easily. NOTE: This package is still under development and not finished. Creat

Oct 15, 2022

ID type with marshalling to/from hash to prevent sending IDs to clients.

ID type with marshalling to/from hash to prevent sending IDs to clients.

Hide IDs Hide is a simple package to provide an ID type that is marshalled to/from a hash string. This prevents sending technical IDs to clients and c

Dec 10, 2022

Endpoints-operator - Kubernetes endpoints balance for outsite apiserver

endpoints-operator 对于集群内访问集群外部服务场景使用固定的endpoint维护增加探活功能 背景 在实际使用中,两个K8s集群内的服务经常有

Dec 9, 2022

rpCheckup is an AWS resource policy security checkup tool that identifies public, external account access, intra-org account access, and private resources.

rpCheckup is an AWS resource policy security checkup tool that identifies public, external account access, intra-org     account access, and private resources.

rpCheckup - Catch AWS resource policy backdoors like Endgame rpCheckup is an AWS resource policy security checkup tool that identifies public, externa

Dec 26, 2022

Xds - A simple xDS server, distributing Kubernetes service endpoints to clients

xDS Server for gRPC on Kubernetes A simple xDS server, distributing Kubernetes s

Nov 20, 2022

Plays videos using Prometheus, e.g. Bad Apple.

Plays videos using Prometheus, e.g. Bad Apple.

prom_bad_apple Plays videos using Prometheus, e.g. Bad Apple. Inspiration A while back I thought this blog post and the corresponding source code were

Nov 30, 2022

Plays videos using Prometheus and Grafana, e.g. Bad Apple.

Plays videos using Prometheus and Grafana, e.g. Bad Apple.

prometheus_video_renderer Plays videos using Prometheus and Grafana, e.g. Bad Apple. Modes Currently 3 different modes are supported. Bitmap The bitma

Nov 30, 2022

A tool written in GO to demonstrate how bad actors utilize requests to spam Discord Users and launch large unsolicited DM Advertisement Campaigns

A tool written in GO to demonstrate how bad actors utilize requests to spam Discord Users and launch large unsolicited DM Advertisement Campaigns

discord-mass-DM-GO A tool written in GO to demonstrate how bad actors utilize requests to spam Discord Users and launch large unsolicited DM Advertise

Jan 2, 2023

Vocabular checker JetBrains Academy home work Read file with bad words

Vocabulary Checker JetBrains Academy home work Read file with bad words and replace them on * in the next entered text until exitVocabulary Checker JetBrains Academy home work Read file with bad words and replace them on * in the next entered text until exit

Jan 14, 2022

Example code to demonstrate how to mock external clients via context.Context

Mocking external client libraries using context.Context This code is paired with a blog post: Mocking external client libraries using context.Context

Nov 6, 2022

go-xss is a module used to filter input from users to prevent XSS attacks

go-xss 根据白名单过滤 HTML(防止 XSS 攻击) go-xss is a module used to filter input from users to prevent XSS attacks go-xss是一个用于对用户输入的内容进行过滤,以避免遭受 XSS 攻击的模块

Nov 3, 2022

Prevent Kubernetes misconfigurations from ever making it (again 😤) to production! The CLI integration provides policy enforcement solution to run automatic checks for rule violations. Docs: https://hub.datree.io

Prevent Kubernetes misconfigurations from ever making it  (again 😤) to production! The CLI integration provides policy enforcement solution to run automatic checks for rule violations.  Docs: https://hub.datree.io

What is Datree? Datree helps to prevent Kubernetes misconfigurations from ever making it to production. The CLI integration can be used locally or in

Jan 1, 2023

A server that proxies requests and uses fhttp & my fork of CycleTLS to modify your clienthello and prevent your requests from being fingerprinted.

TLS-Fingerprint-API A server that proxies requests and uses my fork of CycleTLS & fhttp (fork of net/http) to prevent your requests from being fingerp

Jan 7, 2023

Run proprietary modpack in built in Darwin/macOS sandbox-exec to prevent it from doing malicious things.

Run proprietary modpack in built in Darwin/macOS sandbox-exec to prevent it from doing malicious things.

sandbox-exec lunarclient Run LunarClient in built in Darwin/macOS sandbox-exec to prevent lunar from taking screenshots of your desktop. LunarClient l

Jul 12, 2022
An example module for k6.io to get a cognito access token using USER_SRP_AUTH flow.

xk6-cognito An example module for k6.io to get a cognito access token using USER_SRP_AUTH flow. See: to create k6 extension: https://github.c

Nov 15, 2022
An authorization library that supports access control models like ACL, RBAC, ABAC in Golang
An authorization library that supports access control models like ACL, RBAC, ABAC in Golang

Casbin News: still worry about how to write the correct Casbin policy? Casbin online editor is coming to help! Try it at: https://casbin.org/editor/ C

Jan 2, 2023
goRBAC provides a lightweight role-based access control (RBAC) implementation in Golang.

goRBAC goRBAC provides a lightweight role-based access control implementation in Golang. For the purposes of this package: * an identity has one or mo

Dec 29, 2022
An authorization library that supports access control models like ACL, RBAC, ABAC in Golang
An authorization library that supports access control models like ACL, RBAC, ABAC in Golang

Casbin News: still worry about how to write the correct Casbin policy? Casbin online editor is coming to help! Try it at: https://casbin.org/editor/ C

Jan 4, 2023
Certificate authority and access plane for SSH, Kubernetes, web applications, and databases

Teleport is an identity-aware, multi-protocol access proxy which understands SSH, HTTPS, Kubernetes API, MySQL and PostgreSQL wire protocols.

Jan 9, 2023
Role Based Access Control (RBAC) with database persistence

Authority Role Based Access Control (RBAC) Go package with database persistence Install First get authority go get github.com/harranali/authority Next

Dec 8, 2022
Key-Checker - Go scripts for checking API key / access token validity
Key-Checker - Go scripts for checking API key / access token validity

Key-Checker Go scripts for checking API key / access token validity Update V1.0.0 ?? Added 37 checkers! Screenshoot ?? How to Install go get github.co

Dec 19, 2022
Microservice generates pair of access and refresh JSON web tokens signed by user identifier.

go-jwt-issuer Microservice generates pair access and refresh JSON web tokens signed by user identifier. ?? Deployed on Heroku Run tests: export SECRET

Nov 21, 2022
🔑 Authz0 is an automated authorization test tool. Unauthorized access can be identified based on URL and Role.
🔑 Authz0 is an automated authorization test tool. Unauthorized access can be identified based on URL and Role.

Authz0 is an automated authorization test tool. Unauthorized access can be identified based on URL and Role. URLs and Roles are managed as YAML-based

Dec 20, 2022
Oct 1, 2022