Skip to content

priobike/priobike-shlink-guard

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

priobike-shlink-guard

This is a proxy that can be used in front of a Shlink service to make sure that only valid requests and espacially valid long links are sent to the Shlink. If a link is valid, it gets proxied to the Shlink. Otherwise, an error is returned.

Valid means in our PrioBike-context that the long link represents a shortcut-sharing-link consisting of a base64 encoded json shortcut object.

This service is only useful when used in combination with a Shlink service. It is not a standalone service.

Learn more about PrioBike

Quickstart

Run locally using Docker:

docker-compose up

Configuration is done via environment variables. The following environment variables are available:

  • PROXY_TARGET - The URL of the Shlink service
  • LOG_LEVEL - Differentiates between debug or not debug log level

CLI

Run tests:

go test

API

This service mirrors the Shlink API. It is a subset of the Shlink API. The following endpoints are supported and get validated by this service:

  • POST /rest/v3/short-urls - Create a new short URL
  • GET /rest/v3/short-urls/{shortCode} - Get a short URL by its short code

Every other endpoint is not supported and will be invalid by default.

Example requests

POST

Should not work:

curl -X POST --header "X-Api-Key: secret" -H "Content-Type: application/json" -d @example_long_link_base64_invalid.json  http://localhost/rest/v3/short-urls

Should work:

curl -X POST --header "X-Api-Key: secret" -H "Content-Type: application/json" -d @example_long_link_shortcut_location.json  http://localhost/rest/v3/short-urls

GET

Should not work:

curl -X GET --header "X-Api-Key: secret" -H "Content-Type: application/json" http://localhost/rest/v3/short-urls

Should work (if short link exists):

curl -X GET --header "X-Api-Key: secret" -H "Content-Type: application/json" http://localhost/rest/v3/short-urls/segrs4

Contributing

We highly encourage you to open an issue or a pull request. You can also use our repository freely with the MIT license.

Every service runs through testing before it is deployed in our release setup. Read more in our PrioBike deployment readme to understand how specific branches/tags are deployed.

Anything unclear?

Help us improve this documentation. If you have any problems or unclarities, feel free to open an issue.

About

Proxy guarding our shlink service

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •