Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs (saml): add a pkg level readme and a godoc link #111

Merged
merged 1 commit into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,8 @@ if result.Success {

### [`saml package`](./saml)

[![Go Reference](https://pkg.go.dev/badge/github.com/hashicorp/cap/saml.svg)](https://pkg.go.dev/github.com/hashicorp/cap/saml)

A package for writing clients that integrate with SAML Providers.

The SAML library orients mainly on the implementation profile for
Expand Down
47 changes: 47 additions & 0 deletions saml/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@

# [`saml package`](./saml)

[![Go Reference](https://pkg.go.dev/badge/github.com/hashicorp/cap/saml.svg)](https://pkg.go.dev/github.com/hashicorp/cap/saml)

A package for writing clients that integrate with SAML Providers.

The SAML library orients mainly on the implementation profile for
[federation interoperability](https://kantarainitiative.github.io/SAMLprofiles/fedinterop.html)
(also known as interoperable SAML), a set of software conformance requirements
intended to facilitate interoperability within the context of full mesh identity
federations. It supports the Web Browser SSO profile with HTTP-Post and
HTTP-Redirect as supported service bindings. The default SAML settings follow
the requirements of the interoperable SAML
[deployment profile](https://kantarainitiative.github.io/SAMLprofiles/saml2int.html#_service_provider_requirements).

## Example usage

```go
// Create a new saml config providing the necessary provider information:
cfg, err := saml.NewConfig(<entityID>, <acs>, <metadata>, options...)
// handle error

// Use the config to create the service provider:
sp, err := saml.NewServiceProvider(cfg)
// handle error

// With the service provider you can create saml authentication requests:

// Generate a saml auth request with HTTP Post-Binding
template, err := sp.AuthRequestPost("relay state", options...)
// handle error

// Generate a saml auth request with HTTP Request-Binding
redirectURL, err := sp.AuthRequestRedirect("relay state", options...)
// handle error

// Parsing a SAML response:
r.ParseForm()
samlResp := r.PostForm.Get("SAMLResponse")

response, err := sp.ParseResponse(samlResp, "Response ID", options...)
// handle error
```

You can find the full demo code in the [`saml/demo`](./saml/demo/main.go)
package.
Loading