FBA Auth
Form-based authentication for SharePoint On-Premises

Struct

1
type AuthCnfg struct {
2
// SPSite or SPWeb URL, which is the context target for the API calls
3
SiteURL string `json:"siteUrl"`
4
// Username for SharePoint On-Prem,
5
// format depends in FBA settings, can include domain or doesn't
6
Username string `json:"username"`
7
// User password
8
Password string `json:"password"`
9
}
Copied!

JSON

private.json sample:
1
{
2
"siteUrl": "https://www.contoso.com/sites/test",
3
"username": "john.doe",
4
"password": "this-is-not-a-real-password"
5
}
Copied!

Code sample

1
package main
2
3
import (
4
"log"
5
// "os"
6
7
"github.com/koltyakov/gosip"
8
strategy "github.com/koltyakov/gosip/auth/fba"
9
)
10
11
func main() {
12
// authCnfg := &strategy.AuthCnfg{
13
// SiteURL: os.Getenv("SPAUTH_SITEURL"),
14
// Username: os.Getenv("SPAUTH_USERNAME"),
15
// Password: os.Getenv("SPAUTH_PASSWORD"),
16
// }
17
// or using `private.json` creds source
18
19
authCnfg := &strategy.AuthCnfg{}
20
configPath := "./config/private.json"
21
if err := authCnfg.ReadConfig(configPath); err != nil {
22
log.Fatalf("unable to get config: %v", err)
23
}
24
25
client := &gosip.SPClient{AuthCnfg: authCnfg}
26
// use client in raw requests or bind it with Fluent API ...
27
}
Copied!
Last modified 1yr ago
Export as PDF
Copy link