go-wsfed
The wsfed
package provides functionality for:
- Generating a redirect url to an IDP
- Parsing Tokens generated by an IDP (currently only SAML v1.1 Tokens are supported since that was my specific use case, but it wouldn't take much work to add other Tokens)
Install
go get github.com/ma314smith/go-wsfed
Examples
Configuration
config = wsfed.Config{}
config.MetadataURL = "https://idp.example.com/wsfederation/metadata"
config.MetadataCertsAreTrusted = true
config.MetadataRefreshIntervalSeconds = 604800
config.Realm = "http://realm.example.com"
sso = wsfed.New(&config)
Get the Request URL for the IDP
rp := sso.GetDefaultRequestParameters()
url, err := sso.GetRequestURL(rp)
Parse Claims asserted by the IDP
wresult := r.PostFormValue("wresult")
claims, err := sso.ParseResponse(wresult)
Contributions
Contributions are welcome. Just fork the repo and send a pull request.