I am evaluating Tyk. I want to build a custom plugin GitHub - TykTechnologies/custom-go-plugin: A barebones repository for creating & developing go plugins.. After bringing up localhost:3000, it’s asking for a license key. It said I can signup for a free trial license. However, after signing up, there is no license key sending to me nor option for me to obtain the license key. Please advise.
This is no longer the case @Olu . I signed up, but don’t receive the license key. I have to email to request for a 14 day trial license. Btw, after activating with provided license key, it asks me to login. How do I find out the username / password to login? Is there a default account? If not, how do I set it up?
I suspected the process had changed since the page itself has changed from the linked reply in 2022. Glad that’s sorted now
You can find out the username from the dependent dashboard DB. The password is the tricky part since a one-way hash is used. If you are using MongoDB, you could hack it by finding the password field in the tyk_analytics_users
document field and replace it with this value $2a$10$R1tyvnO67F9Illn8VAA25OT4tmslUkHtj7SZ6phUnqpnco3.PxeHy
. The value is the hash for P@ssw0rd
, so you can now use that to sign in and change it later after successfully logging in.
Well no, but a bootstrap form/page is typically presented on the first run of the dashboard
Considering you provided the license, I assume you went through that bootstrap page?
You can simply use our bootstrap CLI to quickly set up one.
Or you can use our dashboard REST API and Admin REST API to do it. The bootstrap script /opt/tyk-dashboard/install/bootstrap.sh
does the same thing underneath. I have linked an HTTP sample that shows part if the user creation process.
@hostname = <dashboard-domain-or-ip-address>
@port = <dashboard-port>
@dashboard_secret = <dashboard-admin-secret(you can find this in your config)>
@org_id = <existing-dashboard-org-id>
#########################################
# Create a user definition
#########################################
# Body
# =====
# * org_id (organisation id):
# ^ You can also create a user without an org_id.
# ^ This will create a "Super User", who has
# ^ global access to all APIs, Policies, etc, for
# ^ all organisations created within Tyk.
# ===========================================
# @name createUser
POST /admin/users HTTP/1.1
Host: {{hostname}}:{{port}}
admin-auth: {{dashboard_secret}}
{
"active": true,
"email_address": "[email protected]",
"first_name": "Tyk",
"last_name": "Admin",
"org_id": "{{org_id}}",
"user_permissions": {
"IsAdmin": "admin"
}
}
############################################
# Create a passord for the user definition
###########################################
@userId = {{createUser.response.body.$.Meta.id}}
@userAccessKey = {{createUser.response.body.$.Meta.access_key}}
##################################
POST /api/users/{{userId}}/actions/reset HTTP/1.1
Host: {{hostname}}:{{port}}
Authorization: {{userAccessKey}}
{
"new_password":"password",
"user_permissions": {
"IsAdmin":"admin",
"ResetPassword":"admin"
}
}
Just to make things clear, you don’t need a license to build a custom plugin.
Dashboard on the star, if it does not have any user, it will first show you screen to create a first user.
If you do not see this special screen, then you already has some user, probably from previous attempt of installing Tyk…
So if you really do not remember it, you can just remove all users from DB, or just nuke the whole mongo db, if it does not contain anything useful.
Thanks @Olu. I ended up using GitHub - TykTechnologies/tyk-pro-docker-demo: Tyk Pro demo using docker and docker compose, supercedes tyk_quickstart and was able to login with the provided account and see the dashboard. I then use the custom plugin built from GitHub - TykTechnologies/custom-go-plugin: A barebones repository for creating & developing go plugins. to add to my example API, but encountered this error:
tyk-gateway | time="Sep 11 04:10:51" level=info msg="Checking security policy: Open" api_id=260d6de88ac34321597557d2b1dfe6f4 api_name=Example org_id=66e0b6c7e6994f0001f06281
tyk-gateway | time="Sep 11 04:10:51" level=error msg="Could not load Go-plugin" error="plugin.Open(\"/opt/tyk-gateway/middleware/CustomGoPlugin_v5.4.0_linux_amd64\"): plugin was built with a different version of package go.opentelemetry.io/otel/internal" mwPath=/opt/tyk-gateway/middleware/CustomGoPlugin.so mwSymbolName=AddFooBarHeader
Hi,
I guess you built the plugin using the make build
or make bundle
commands?
Unfortunately there have been changes in golang and in Tyk Plugin Compiler that stop these make
commands working in some gateway versions.
If it’s just the plugin that’s being built, please follow the example below. I’ve cloned custom-go-plugins
under my ~/code
but replace that with your repo copy.
~/code/custom-go-plugin$ cd go/src
~/code/custom-go-plugin/go/src$ rm -rf go.mod go.sum vendor/
~/code/custom-go-plugin/go/src$ docker container run -v $PWD:/plugin-source --env GO_TIDY=1 --env GO_GET=1 --rm tykio/tyk-plugin-compiler:v5.4.0 CustomGoPlugin.so $(date +%s%N)
This will build a plugin and give it a unique build number (which is important when you want to change the plugin without restarting the gateway.)
After this completes you’ll have a directory that looks like this
~/code/custom-go-plugin/go/src$ ls -l
total 28032
-rw-rw-r-- 1 user group 952 Sep 12 10:56 CustomGoPlugin.go
-rw-r–r-- 1 root root 28697264 Sep 12 10:57 CustomGoPlugin_v5.4.0_linux_amd64.so
And the plugin shared object will load into a 5.4.0 gateway without issues.
Cheers,
Pete