Commit Graph

37 Commits

Author SHA1 Message Date
sputn1ck
b1b0dc5570 proxy: add skipping invoice creation on request 2025-05-15 08:41:03 +02:00
sputn1ck
324c27dd55 proxy: set Content-Type for gRPC requests
Prior we would not set the Content-Type header for
grpc request, which on failure events would cause
the response to be invalid gRPC responses, as the
grpc code path in sendDirectResponse expects the
Content-Type header to be set.

This change fixes the problem by setting the
Content-Type header to application/grpc for gRPC
requests.
2025-05-14 22:23:32 +02:00
sputn1ck
1557c4aef9 proxy: precompile regexp 2025-05-14 22:12:25 +02:00
djkazic
d8e17e2da3 proxy: implement blocklist 2025-05-14 09:54:34 -04:00
Oliver Gugger
9ad67ea672 proxy+auth: fix post request 2024-05-24 08:36:06 +02:00
Boris Nagaev
7579f92a08 auth: don't send client's headers back
Create fresh http.Header object filled with the only header:
"Content-Type: application/grpc".
2024-04-23 09:27:49 -03:00
Boris Nagaev
a4431801ef multi: replace LSAT with L402
auth: LsatAuthenticator -> L402Authenticator
sed -i 's/LsatAuthenticator/L402Authenticator/g' aperture.go auth/authenticator.go auth/authenticator_test.go

rename package lsat to l402
git mv lsat/ l402
sed 's@aperture/lsat@aperture/l402@g' -i `git grep -l aperture/lsat`
sed -i 's@package lsat@package l402@' `git grep -l 'package lsat'`
sed -i 's@lsat\.@l402.@g' -i `git grep -l 'lsat\.'`
sed 's@l402.Id@lsat.Id@' -i mint/mint_test.go

replace lsat with l402 in the code
sed 's@lsat@l402@' -i mint/mint_test.go
sed 's@Lsat@L402@' -i l402/client_interceptor.go
sed 's@lsatstore@l402store@' -i l402/store_test.go

replace LSAT to L402 in comments
sed '/\/\//s@LSAT@L402@g' -i `git grep -l '//.*LSAT'`

replace LSAT -> L402 in the code, skip when a string starts with it
sed 's@\([^"/]\)LSAT@\1L402@g' -i `git grep -l LSAT`
2024-04-16 19:33:03 -03:00
Oliver Gugger
e2757ebca8 proxy: always return 200 status code to gRPC client
It turns out that sending a non-200 HTTP status code was against the
gRPC spec and the older versions of the `grpc` library just didn't
validate that. The validation was added in v1.40.0, which is the version
that we couldn't update to before.
With this fix the error is still parsed correctly on the client side.
But this requires a small change to the L402 spec because the status
code is no longer 402.
2023-06-15 13:32:14 +02:00
Olaoluwa Osuntokun
40df8f8339 proxy+pricer: pass in the entire HTTP requests for GetPrice
In this commit, we modify the `GetPrice` method and interface to accept
the full request instead of _just_ the path. For backwards compat, we
leave the path in place, but also include the full serialized HTTP
request.
2023-06-13 20:43:14 -05:00
Oliver Gugger
27f3a1e15a multi: fix grpc version issue 2023-02-27 13:36:56 +01:00
ffranr
db30c8384d lint: remove depreciated io/ioutil
As of Go 1.16, functionality provided in io/ioutil has been depreciated
in favour of the io or os packages. Now that Go has been
upgraded in go.mod, the linter will not pass without these changes.
2023-01-27 13:27:38 +00:00
ffranr
73ed7bfc52 lint: rename private struct field: freebieDb
freebieDb -> freebieDB
Change suggested by linter stylecheck (rule: ST1003).
2023-01-27 12:41:18 +00:00
Oliver Gugger
c45cd3a317 proxy+aperture: refactor to local service
We want aperture to handle some of the incoming requests on its own,
without forwarding/proxying them to a remote backend. Those "local"
services can register themselves and will be given every request for
inspection. If a service decides to handle it locally, the request is
passed to that service and not forwarded.
2021-11-24 17:32:46 +01:00
Elle Mouton
a955d9174b multi: add and use DynamicPrice option
This commit adds a DynamicPrice member to the Services struct and uses
its values to determine if a GRPCPricer or DefaultPricer should be
initialised. The commit also updates the sample-conf.yaml file with the
new config options.
2021-08-03 14:31:00 +02:00
Elle Mouton
853b131d80 multi: cleanup proxy
This commit adds to ability to cleanup the Proxy by adding a Close
method and calling this method during server shut down.
2021-08-03 14:30:55 +02:00
Oliver Gugger
74282b9978 proxy: remove manual trailer fields
The last bugfix added some explicit header fields in an attempt of
fixing an issue with error responses. Unfortunately they weren't
strictly needed for the fix but ended up causing issues in a non-error
case.
This commit removes those header fields again and makes sure the "auth
header not found in response" header doesn't occur anymore.
2021-05-31 21:11:19 +02:00
Oliver Gugger
cf11bcc626 proxy: reproduce and fix weird HTTP/2 error 2021-05-11 13:25:25 +02:00
Oliver Gugger
ec089c4723 config+proxy: disable static file serving by default 2020-07-17 11:09:23 +02:00
Elle Mouton
162571ac45 aperture: Custom price per service 2020-05-13 09:57:40 +02:00
Oliver Gugger
59268f8f59 auth+lsat: move LSAT specific code 2020-03-19 16:16:34 +01:00
Olaoluwa Osuntokun
0c14706fa4 aperture: propagate rename 2020-03-18 13:57:18 -07:00
Oliver Gugger
c6c62b9472 multi: fix all linter errors 2019-12-04 10:58:04 +01:00
Oliver Gugger
c2e9d540ba proxy: add auth whitelist for paths 2019-12-04 10:45:07 +01:00
Wilmer Paulino
95c405b0c7 auth+proxy: extend Authenticator methods with target service name
The target service name remains unused in its current form, but will be
required in order to verify that an incoming request with an LSAT
attached is authorized to access the service being attempted. We can
derive this from the request's host field, but we choose to extend the
methods with the additional parameter in order to prevent parsing the
host field again to determine which service is being accessed.
2019-11-26 11:12:48 -08:00
Oliver Gugger
aef413da0a auth+proxy: forward auth to backend 2019-11-18 10:41:12 +01:00
Oliver Gugger
00f661318f proxy: send error as gRPC error 2019-11-15 09:45:06 +01:00
Oliver Gugger
564deb6545 proxy: add demo and README with the use cases 2019-11-12 12:02:14 +01:00
Oliver Gugger
e704ba4aa9 proxy: add prefix logger to log remote IP address 2019-11-12 12:02:14 +01:00
Oliver Gugger
38c17f4de8 proxy: dispatch all non-matched requests to static file server 2019-11-12 12:02:14 +01:00
Oliver Gugger
672766b340 proxy: allow update of backend services 2019-11-12 12:02:13 +01:00
Oliver Gugger
c8cbeb9ab1 config: add static file root 2019-11-06 13:21:56 +01:00
Oliver Gugger
a44e9fbd22 freebie+proxy: add memory based freebie DB implementation 2019-11-06 13:21:56 +01:00
Oliver Gugger
83395c0c98 proxy+auth: add log statements 2019-11-06 13:21:55 +01:00
Oliver Gugger
5a3b8b79d2 proxy: implement basic proxy functionality 2019-11-06 13:21:45 +01:00
Oliver Gugger
4d1fbbf4d6 proxy: add static file server 2019-11-04 12:43:31 +01:00
Oliver Gugger
9552a70cb9 proxy: match service with regular expressions 2019-11-04 12:43:25 +01:00
Valentine Wallace
279fa2a64b Initial version of the proxy.
Missing: logging, an Authenticator implementing the LSAT HTTP
and gRPC protocol.
2019-09-12 16:41:25 -07:00