Custom Auth
Custom authentication mechanisms
Gosip allows providing custom authentication mechanisms. For example, you are considering reusing Fluent API helpers and HTTP Client but existing authentication strategies do not feet your environment specifics. Maybe your tenant configured with custom ADFS provider, maybe it's 2FA and there are no alternatives and you need On-Demand auth, but it missed in Gosip strategies list? Fortunately, this is not any sort of stopper. All included authentication strategies are a sort of a pluging and it's rather affordable to add a new strategy on your own.
Let's take a look at any strategy binding:
What we can see? Some strategy is imported into the strategy
namespace. A strategy has AuthCnfg
struct with some public properties which are obviously taking place in authentication flow. This struct is then passed to &gosip.SPClient{AuthCnfg: authCnfg}
and somehow after following binding the requests are authenticated.
For this construction to work strategy.AuthCnfg
should implement gosip.AuthCnfg
interface which is:
Philosophy of the strategies is to have two initiation modes, the first is a strict declaration of the creds and the second one is reading credentials from the config. That config is not necessarily a file on the file system it can be a request to a key vault or OS credential manager, etc.
As the interface is passed to gosip.SPClient
struct, Gosip knows nothing about the creds and the context, for that reason GetSiteURL
method is vital to target requests to a correct root URL.
GetStrategy
method should return the string alias value of the strategy name if something specific should be happening based on its value.
By implementing AuthCnfg struct and gosip.AuthCnfg interface any custom authentication can be added to Gosip.
Last updated
Was this helpful?