Skip to content

Latest commit

 

History

History
142 lines (111 loc) · 5.71 KB

README.md

File metadata and controls

142 lines (111 loc) · 5.71 KB

Ory.Oathkeeper.Client - the C# library for the ORY Oathkeeper

ORY Oathkeeper is a reverse proxy that checks the HTTP Authorization for validity against a set of rules. This service uses Hydra to validate access tokens and policies.

This C# SDK is automatically generated by the OpenAPI Generator project:

  • API version: v0.40.6
  • SDK version: 0.40.6
  • Build package: org.openapitools.codegen.languages.CSharpNetCoreClientCodegen For more information, please visit https://www.ory.am

Frameworks supported

Dependencies

The DLLs included in the package may not be the latest version. We recommend using NuGet to obtain the latest version of the packages:

Install-Package RestSharp
Install-Package Newtonsoft.Json
Install-Package JsonSubTypes
Install-Package System.ComponentModel.Annotations

NOTE: RestSharp versions greater than 105.1.0 have a bug which causes file uploads to fail. See RestSharp#742. NOTE: RestSharp for .Net Core creates a new socket for each api call, which can lead to a socket exhaustion problem. See RestSharp#1406.

Installation

Run the following command to generate the DLL

  • [Mac/Linux] /bin/sh build.sh
  • [Windows] build.bat

Then include the DLL (under the bin folder) in the C# project, and use the namespaces:

using Ory.Oathkeeper.Client.Api;
using Ory.Oathkeeper.Client.Client;
using Ory.Oathkeeper.Client.Model;

Packaging

A .nuspec is included with the project. You can follow the Nuget quickstart to create and publish packages.

This .nuspec uses placeholders from the .csproj, so build the .csproj directly:

nuget pack -Build -OutputDirectory out Ory.Oathkeeper.Client.csproj

Then, publish to a local feed or other host and consume the new package via Nuget as usual.

Usage

To use the API client with a HTTP proxy, setup a System.Net.WebProxy

Configuration c = new Configuration();
System.Net.WebProxy webProxy = new System.Net.WebProxy("http://myProxyUrl:80/");
webProxy.Credentials = System.Net.CredentialCache.DefaultCredentials;
c.Proxy = webProxy;

Getting Started

using System.Collections.Generic;
using System.Diagnostics;
using Ory.Oathkeeper.Client.Api;
using Ory.Oathkeeper.Client.Client;
using Ory.Oathkeeper.Client.Model;

namespace Example
{
    public class Example
    {
        public static void Main()
        {

            Configuration config = new Configuration();
            config.BasePath = "http://localhost";
            var apiInstance = new ApiApi(config);

            try
            {
                // Access Control Decision API
                apiInstance.Decisions();
            }
            catch (ApiException e)
            {
                Debug.Print("Exception when calling ApiApi.Decisions: " + e.Message );
                Debug.Print("Status Code: "+ e.ErrorCode);
                Debug.Print(e.StackTrace);
            }

        }
    }
}

Documentation for API Endpoints

All URIs are relative to http://localhost

Class Method HTTP request Description
ApiApi Decisions GET /decisions Access Control Decision API
ApiApi GetRule GET /rules/{id} Retrieve a Rule
ApiApi GetWellKnownJSONWebKeys GET /.well-known/jwks.json Lists Cryptographic Keys
ApiApi ListRules GET /rules List All Rules
HealthApi IsInstanceAlive GET /health/alive Check alive status
HealthApi IsInstanceReady GET /health/ready Check readiness status
VersionApi GetVersion GET /version Get service version

Documentation for Models

Documentation for Authorization

All endpoints do not require authorization.