http_auth_random

command
v0.0.0-...-af5a433 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 31, 2020 License: Apache-2.0 Imports: 3 Imported by: 0

README

http_auth_random

this example authorize requests depending on the hash values of a response from http://httpbin.org/uuid.

build && run

tinygo build -o wasm.wasm -wasm-abi=generic -target wasm ./main.go && docker-compose up

now you can make requests authorized randomly:

$ curl localhost:18000/uuid -v
*   Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 18000 (#0)
> GET /uuid HTTP/1.1
> Host: localhost:18000
> User-Agent: curl/7.54.0
> Accept: */*
>
< HTTP/1.1 200 OK
< date: Wed, 25 Mar 2020 09:06:33 GMT
< content-type: application/json
< content-length: 53
< server: envoy
< access-control-allow-origin: *
< access-control-allow-credentials: true
< x-envoy-upstream-service-time: 1056
<
{
  "uuid": "e1020f65-f97a-47cd-9b31-368ba2063b6a"
}



# curl localhost:18000/uuid -v
*   Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 18000 (#0)
> GET /uuid HTTP/1.1
> Host: localhost:18000
> User-Agent: curl/7.54.0
> Accept: */*
>
< HTTP/1.1 403 Forbidden
< content-length: 16
< content-type: text/plain
< powered-by: proxy-wasm-go!!
< date: Wed, 25 Mar 2020 09:07:36 GMT
< server: envoy
<
* Connection #0 to host localhost left intact
access forbidden

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL