gosip: github.com/koltyakov/gosip Index | Files | Directories

package gosip

import "github.com/koltyakov/gosip"

Package gosip is pure Go library for dealing with SharePoint unattended authentication and API consumption.

It supports a variety of different authentication strategies such as:

- ADFS user credentials
- Auth to SharePoint behind a reverse proxy (TMG, WAP)
- Form-based authentication (FBA)
- Add-in only permissions
- SAML based with user credentials

Amongst supported platform versions are:

- SharePoint Online (SPO)
- On-Premise: 2019, 2016, and 2013


Package Files

digest.go gosip.go hooks.go retry.go

func GetDigest Uses

func GetDigest(context context.Context, client *SPClient) (string, error)

GetDigest retrieves and caches SharePoint API X-RequestDigest value

type AuthCnfg Uses

type AuthCnfg interface {
    SetAuth(req *http.Request, client *SPClient) error // Authentication middleware fabric
    GetSiteURL() string                                // SiteURL getter method
    GetStrategy() string                               // Strategy code getter (triggered on demand)
    ReadConfig(configPath string) error                // Reads credentials from storage (triggered on demand)
    WriteConfig(configPath string) error               // Writes credential to storage (triggered on demand)
    GetAuth() (string, error)                          // Authentication initializer

AuthCnfg is an abstract auth config interface, allows different authentications strategies' dependency injection

type HookEvent Uses

type HookEvent struct {
    Request    *http.Request
    StartedAt  time.Time
    StatusCode int
    Error      error

HookEvent hook event parameters struct

type HookHandlers Uses

type HookHandlers struct {
    OnError    func(event *HookEvent) // when error appeared
    OnRetry    func(event *HookEvent) // before retry request
    OnRequest  func(event *HookEvent) // before request is sent
    OnResponse func(event *HookEvent) // after response is received

HookHandlers struct to configure events handlers

type SPClient Uses

type SPClient struct {
    AuthCnfg   AuthCnfg // authentication configuration interface
    ConfigPath string   // private.json location path, optional when AuthCnfg is provided with creds explicitly

    RetryPolicies map[int]int   // allows redefining error state requests retry policies
    Hooks         *HookHandlers // hook handlers definition

SPClient : SharePoint HTTP client struct

func (*SPClient) Execute Uses

func (c *SPClient) Execute(req *http.Request) (*http.Response, error)

Execute : SharePoint HTTP client is a wrapper for standard http.Client' `Do` method, injects authorization tokens, etc.


apiPackage api represents Fluent API for SharePoint object model
auth/addinPackage addin implements AddIn Only Auth
auth/adfsPackage adfs implements ADFS Auth (user credentials authentication)
auth/anonPackage anon provides anonymous "strategy" no auth mechanisms are applied to the requests
auth/fbaPackage fba implements FBA (Form-based authentication)
auth/ntlmPackage ntlm implements NTLM Auth (NTLM handshake)
auth/samlPackage saml implements SAML Auth (SharePoint Online user credentials authentication)
auth/tmgPackage tmg implements FBA authentication behind TMG (Microsoft Forefront Threat Management Gateway)
csomPackage csom helps building CSOM XML requests

Package gosip imports 13 packages (graph) and is imported by 10 packages. Updated 2020-09-21. Refresh now. Tools for package owners.