I am getting this error while compiling a simple auth plugin
cannot use key (variable of type string) as bool value in argument to ctx.SetSession
I used these steps to compile plugins and these steps have been tested with non-auth plugins (even compilation of auth plugin work if I replace ctx.SetSession(r, session, key, true)
with ctx.SetSession(r, session, true, true)
but this isn’t right since session isn’t created/cached in Redis):
rm -rf go.mod go.sum vendor/
go mod init tyk-plugin
go mod edit -replace github.com/jensneuse/graphql-go-tools=github.com/TykTechnologies/[email protected]
go get github.com/TykTechnologies/tyk@af3430ae6e1ca689365bf67416c590d3201b7929
<Write and finalize code>
go mod tidy
go mod vendor
docker container run -v $(pwd):/plugin-source --rm tykio/tyk-plugin-compiler:v4.0.4 plugin.so
I think we should update GitHub - TykTechnologies/custom-plugin-examples: Custom plugin examples for the Tyk Gateway - if you ever needed to extend the functionality! and docs to support latest version of tyk.
Related:
opened 11:45AM - 22 Aug 22 UTC
Current examples are using older versions of tyk. I think we should update examp… les to support latest version
I was able to compile few basic examples for 4.0.4 version using these steps:
```
rm -rf go.mod go.sum vendor/
go mod init tyk-plugin
go mod edit -replace github.com/jensneuse/graphql-go-tools=github.com/TykTechnologies/[email protected]
go get github.com/TykTechnologies/tyk@af3430ae6e1ca689365bf67416c590d3201b7929
<Write and finalize code>
go mod tidy
go mod vendor
docker container run -v $(pwd):/plugin-source --rm tykio/tyk-plugin-compiler:v4.0.4 plugin.so
```
Signature of ctx.SetSession is changed in latest version that's why [go-auth-multiple_hook_example](https://github.com/TykTechnologies/custom-plugins/blob/master/plugins/go-auth-multiple_hook_example/main.go) isn't compiling.
Related: https://community.tyk.io/t/go-auth-plugin-example-with-latest-tyk-version-v4-0-4/5635
Hi Tyk community!
I have developed a Golang plugin that I use like this:
"custom_middleware": {
"pre": [],
"auth_check": {
"name": "CheckAuthentication",
"path": "./plugins/keycloak/keycloak.so"
},
...
}
I’m using tykio/tyk-gateway:v3.2.2 version and I compile the plugin with:
docker run --rm -v `pwd`:/plugin-source tykio/tyk-plugin-compiler:v3.2.2 keycloak.so
The plugin gets called, but I always get the error:
{
"error": "Session state …
committed 07:31PM - 29 Mar 22 UTC
## Description
In order to be fully backward compatible, then updated the signa… ture of `ctx.SetSession` function, now it will infer from where to get the configuration if keys should be hashed or not. When a gw starts then it will override the function `Global func() Config` that resides inside the config package, in this way it will take automatically the configurtion of the current gateway.
## Related Issue
[ticket](https://tyktech.atlassian.net/browse/TT-4934)
## Motivation and Context
Unblock release
## How This Has Been Tested
- Ran GW
- Created a key and consume api
## Screenshots (if appropriate)
## Types of changes
- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
- [ ] Refactoring or add test (improvements in base code or adds test coverage to functionality)
## Checklist
- [x] Make sure you are requesting to **pull a topic/feature/bugfix branch** (right side). If pulling from your own
fork, don't request your `master`!
- [x] Make sure you are making a pull request against the **`master` branch** (left side). Also, you should start
*your branch* off *our latest `master`*.
- [ ] My change requires a change to the documentation.
- [ ] If you've changed APIs, describe what needs to be updated in the documentation.
- [ ] If new config option added, ensure that it can be set via ENV variable
- [ ] I have updated the documentation accordingly.
- [ ] Modules and vendor dependencies have been updated; run `go mod tidy && go mod vendor`
- [ ] When updating library version must provide reason/explanation for this update.
- [ ] I have added tests to cover my changes.
- [ ] All new and existing tests passed.
- [x] Check your code additions will not fail linting checks:
- [x] `go fmt -s`
- [ ] `go vet`
Ubong
August 24, 2022, 12:37pm
2
Hey @armujahid ,
Thanks for posting this here. I’ve created an internal ticket to this end.
1 Like