Skip to content

Commit

Permalink
New overload for token auth accepting supplier #252
Browse files Browse the repository at this point in the history
  • Loading branch information
Lanayx committed Feb 12, 2024
1 parent 07df121 commit c5f12c2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
11 changes: 10 additions & 1 deletion src/Pulsar.Client/Api/AuthenticationFactory.fs
Original file line number Diff line number Diff line change
@@ -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.
[<AbstractClass; Sealed>]
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<string>) : 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

11 changes: 7 additions & 4 deletions src/Pulsar.Client/Auth/DefaultImplementation.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
new AuthenticationOauth2(issuerUrl, audience, privateKey, scope)
6 changes: 3 additions & 3 deletions src/Pulsar.Client/Pulsar.Client.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
<Title>Pulsar.Client</Title>
<RootNamespace>Pulsar.Client</RootNamespace>
<AssemblyName>Pulsar.Client</AssemblyName>
<Version>3.2.0</Version>
<Version>3.3.0</Version>
<Company>F# community</Company>
<Description>.NET client library for Apache Pulsar</Description>
<RepositoryUrl>https://github.com/fsprojects/pulsar-client-dotnet</RepositoryUrl>
<PackageReleaseNotes>Changed several API properties to async methods to avoid deadlocks</PackageReleaseNotes>
<PackageReleaseNotes>New overload for token auth accepting supplier</PackageReleaseNotes>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/fsprojects/pulsar-client-dotnet</PackageProjectUrl>
<RepositoryType>git</RepositoryType>
<PackageTags>pulsar</PackageTags>
<Authors>F# community</Authors>
<PackageVersion>3.2.0</PackageVersion>
<PackageVersion>3.3.0</PackageVersion>
<DebugType>portable</DebugType>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageReadmeFile>README.md</PackageReadmeFile>
Expand Down

0 comments on commit c5f12c2

Please sign in to comment.