Comments (5)
Added in master branch. Will be part of 1.6
Setting auth.use_param
in an API Definition to true
will have tyk look for API tokens in the requests parameters instead of the header. This is case sensitive.
from tyk.
Super. Thank you very much, Martin.
from tyk.
Would it be possible to permit both?
I've never written go before, but would something like this work?
diff --git a/middleware_auth_key.go b/middleware_auth_key.go
index 566d911..a15d820 100644
--- a/middleware_auth_key.go
+++ b/middleware_auth_key.go
@@ -52,14 +52,14 @@ func (k *AuthKey) ProcessRequest(w http.ResponseWriter, r *http.Request, configu
thisConfig := k.TykMiddleware.Spec.APIDefinition.Auth
authHeaderValue := r.Header.Get(thisConfig.AuthHeaderName)
- if thisConfig.UseParam {
+ if thisConfig.UseParam && authHeaderValue = "" {
tempRes := CopyRequest(r)
// Set hte header name
authHeaderValue = tempRes.FormValue(thisConfig.AuthHeaderName)
}
- if thisConfig.UseCookie {
+ if thisConfig.UseCookie && authHeaderValue = "" {
tempRes := CopyRequest(r)
authCookie, notFoundErr := tempRes.Cookie(thisConfig.AuthHeaderName)
if notFoundErr != nil {
Ideally, I'd prefer the ability to set both a header param AND a query param that'll be accepted, so that a request could authenticate with (header) Authorization: foobar
or (query) ?access_token=foobar
; headers are conventionally camel cased and dash-delimited, while query params are conventionally snake cased. It's not a huge deal, but it would be a nice little extra. :)
from tyk.
@cheald It's totally possible, though I would prefer to make it an explicit configuration, either one, the other or both.
Currently, they share a configuration setting (the name of the field). This proposal would require:
- The addition of a new field in the tykcommon API Definition to hold the new data
- The modification of all the middleware and methods that extract version data (there's two I believe) to handle a new field
This would break backwards compatibility, to make it compatible, we would need to introduce behaviour that infers the correct name, i.e. some kind of "sluggifier" that converts headers (I believe these are case insensitive but make use of hyphens) into the respective querystring representation.
It's not ideal, but that's how I'd approach it to make sure it was backwards compatible without adding more data.
In V2 we can add new fields.
If this is something you want to see, open a new issue requesting the capability and it we'll get to it.
from tyk.
- 1
We are going to need the same support for both auth-tokens in querystring and in header.
from tyk.
Related Issues (20)
- Supporting "else" condition in Tyk "url_rewrites.triggers" HOT 3
- Double response from auth go plugin HOT 1
- Whitelist regex includes listenpath even when "strip_listen_path": true HOT 7
- [TT-10626] extended_paths path handling is inconsistent HOT 2
- [TT-10538] Service Discovery support custom method and request body HOT 1
- [TT-10472] CORS.options_passthrough breaks URLRewriteMiddleware HOT 1
- [TT-10384] Is Tyk (gateway) affected by CVE-2023-44487 ? HOT 3
- Endpoint undeclared but currently accessible HOT 4
- Stale Twitter Icon on Website HOT 2
- Dependency check HOT 2
- Feature Request: Dark/Light Mode Toggle HOT 3
- Tyk API Gateway 5.0.7 : When creating the key for Basic Auth, the key value in responce is "" HOT 1
- OAuth2 client_credentials authentication does not seem to be RFC6749 compliant HOT 3
- Rate limit does not get reset when using more than 1 gateway pods in kubernetes HOT 1
- Optimize rate limit using Lua script
- [Q]: Adding more tests and increasing the Code Coverage HOT 4
- Double response from go plugin virtual endpoint HOT 1
- [TT-5070]Wrong HTTP status code when panic happens inside Go plugin HOT 1
- [TT-11223]ERROR: Tyk PUMP not able to connect to Redis Sentinels HOT 1
- Error with middleware in one gateway while other pods are working fine HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tyk.