Skip to content
Tyk rich plugin demo, using a gRPC backend written in C# / .NET.
C#
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Coprocess
.gitignore
Auth.cs
Program.cs
README.md
Server.cs
manifest.json
project.json
settings.sample.json
testdatabase.sql

README.md

.NET gRPC plugin

Plugin overview

This repository provides a sample gRPC plugin, written in .NET, intended to work as part of Tyk. This is written in C# and has been tested using .NET Core.

The project implements a simple request dispatcher, based on Tyk custom middleware hooks. A class takes care of this process, and also implements these hooks methods.

A sample authentication layer, based on Microsoft SQL Server is provided. This could be a useful reference for similar .NET integrations.

The featured hooks are as follows:

MyPreMiddleware

This hook is very simple. It injects a header before the authentication step is performed. You may test this hook without any database setup.

MyAuthCheck

This hook will extract the authorization header and pass it to the authentication layer. The authentication layer initializes a basic SQL Server client, and performs a SQL query to check if the token is valid. A test database dump is included in this repository, in case you want to replicate this scenario, without modifying the authentication layer code.

MyPostMiddleware

This hook will be called after the authentication check.

Requirements

Instructions

After checking the requirements, clone this repository:

$ git clone https://github.com/TykTechnologies/tyk-plugin-demo-dotnet.git

Enter the plugin directory:

$ cd tyk-plugin-demo-dotnet

And install the .NET dependencies:

$ dotnet restore

If the dependencies get installed correctly, you should be able to build the project using:

$ dotnet build

To run the gRPC server use:

$ dotnet run

By default, the gRPC server will listen on port 5555.

Building a bundle

When using gRPC plugin bundles, the manifest file (manifest.json) is limited to the custom middleware definition. The gRPC server and its files are independent from this and its deployment should be handled separately.

Check the sample manifest file for reference.

To build a bundle use:

$ tyk-cli bundle build

You may check the tyk-cli documentation for additional options.

Additional documentation

You can’t perform that action at this time.