gosip

package module
v0.1.34 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 24, 2022 License: MIT Imports: 13 Imported by: 0

README

Gosip - SharePoint authentication, HTTP client & fluent API wrapper for Go (Golang)

go mod tidy git tag v0.1.34 git push origin v0.1.34 go list -m github.com/pnocera/gosip@v0.1.34

Documentation

Overview

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:

Amongst supported platform versions are:

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetDigest

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

GetDigest retrieves and caches SharePoint API X-RequestDigest value

Types

type AuthCnfg

type AuthCnfg interface {
	// GetAuth Authentication initializer (token/cookie/header, expiration, error)
	// to support capability for exposing tokens for external tools
	// e.g. as of this sample project https://github.com/koltyakov/spvault
	GetAuth() (string, int64, error)

	// SetAuth Authentication middleware fabric
	// applies round tripper or enriches requests with authentication and metadata
	SetAuth(req *http.Request, client *SPClient) error

	ParseConfig(jsonConf []byte) error  // Parses credentials from a provided JSON byte array content
	ReadConfig(configPath string) error // Reads credentials from storage

	GetSiteURL() string  // SiteURL getter method
	GetStrategy() string // Strategy code getter

}

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

type HookEvent

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

HookEvent hook event parameters struct

type HookHandlers

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

type SPClient struct {
	http.Client
	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

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.

Directories

Path Synopsis
Package api represents Fluent API for SharePoint object model
Package api represents Fluent API for SharePoint object model
auth
addin
Package addin implements AddIn Only Auth
Package addin implements AddIn Only Auth
adfs
Package adfs implements ADFS Auth (user credentials authentication)
Package adfs implements ADFS Auth (user credentials authentication)
anon
Package anon provides anonymous "strategy" no auth mechanisms are applied to the requests
Package anon provides anonymous "strategy" no auth mechanisms are applied to the requests
fba
Package fba implements FBA (Form-based authentication)
Package fba implements FBA (Form-based authentication)
ntlm
Package ntlm implements NTLM Auth (NTLM handshake)
Package ntlm implements NTLM Auth (NTLM handshake)
saml
Package saml implements SAML Auth (SharePoint Online user credentials authentication)
Package saml implements SAML Auth (SharePoint Online user credentials authentication)
tmg
Package tmg implements FBA authentication behind TMG (Microsoft Forefront Threat Management Gateway)
Package tmg implements FBA authentication behind TMG (Microsoft Forefront Threat Management Gateway)
cmd
Package csom helps building CSOM XML requests
Package csom helps building CSOM XML requests
test

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL