diff --git a/src/Pulsar.Client/Api/AuthenticationFactory.fs b/src/Pulsar.Client/Api/AuthenticationFactory.fs index 0cfa846f..de78dea9 100644 --- a/src/Pulsar.Client/Api/AuthenticationFactory.fs +++ b/src/Pulsar.Client/Api/AuthenticationFactory.fs @@ -1,13 +1,22 @@ namespace Pulsar.Client.Api +open System +open Microsoft.FSharp.Core open Pulsar.Client.Auth +/// Factory class that allows to create Authentication instances for all the supported authentication methods. [] type AuthenticationFactory = + /// Create an authentication provider for token based authentication. static member Token (token: string) : Authentication = DefaultImplementation.newAuthenticationToken token :> Authentication + /// Create an authentication provider for token based authentication. + static member Token (tokenSupplier: Func) : Authentication = + DefaultImplementation.newAuthenticationTokenSupplier(FuncConvert.FromFunc tokenSupplier) :> Authentication + + /// Create an authentication provider for TLS based authentication. static member Tls (certFilePath: string) : Authentication = DefaultImplementation.newAuthenticationTls certFilePath :> Authentication - + diff --git a/src/Pulsar.Client/Auth/DefaultImplementation.fs b/src/Pulsar.Client/Auth/DefaultImplementation.fs index 59719b32..ac3472e6 100644 --- a/src/Pulsar.Client/Auth/DefaultImplementation.fs +++ b/src/Pulsar.Client/Auth/DefaultImplementation.fs @@ -4,11 +4,14 @@ open System open Pulsar.Client.Auth open Pulsar.Client.Auth.OAuth2 +let newAuthenticationTokenSupplier (supplier: unit -> string) = + new AuthenticationToken(supplier) + let newAuthenticationToken (token: string) = - new AuthenticationToken (token) + new AuthenticationToken(token) let newAuthenticationTls (certFilePath: string) = - new AuthenticationTls (certFilePath) - + new AuthenticationTls(certFilePath) + let newAuthenticationOauth2 (issuerUrl : Uri, audience: string, privateKey: Uri, scope: string) = - new AuthenticationOauth2 (issuerUrl, audience, privateKey, scope) \ No newline at end of file + new AuthenticationOauth2(issuerUrl, audience, privateKey, scope) \ No newline at end of file diff --git a/src/Pulsar.Client/Pulsar.Client.fsproj b/src/Pulsar.Client/Pulsar.Client.fsproj index 83e6e711..769781dc 100644 --- a/src/Pulsar.Client/Pulsar.Client.fsproj +++ b/src/Pulsar.Client/Pulsar.Client.fsproj @@ -7,17 +7,17 @@ Pulsar.Client Pulsar.Client Pulsar.Client - 3.2.0 + 3.3.0 F# community .NET client library for Apache Pulsar https://github.com/fsprojects/pulsar-client-dotnet - Changed several API properties to async methods to avoid deadlocks + New overload for token auth accepting supplier MIT https://github.com/fsprojects/pulsar-client-dotnet git pulsar F# community - 3.2.0 + 3.3.0 portable true README.md