scram

package
v0.0.0-...-14f3c7c Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2021 License: BSD-2-Clause Imports: 2 Imported by: 0

Documentation

Overview

Package scram implements a SCRAM-{SHA-1,etc} client per RFC5802.

http://tools.ietf.org/html/rfc5802

Index

Constants

View Source
const (
	// ScramSha1 use the SCRAM-SHA-1 variant
	ScramSha1 = "SCRAM-SHA-1"

	// ScramSha256 use the SCRAM-SHA-256 variant
	ScramSha256 = "SCRAM-SHA-256"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client adapts a SCRAM client (SCRAM-SHA-1, SCRAM-SHA-256).

A Client may be used within a SASL conversation with logic resembling:

mechanism, err := scram.NewMethod("SCRAM-SHA-256")

if err != nil {
  log.Fatal(err)
}

var in []byte
var client = scram.NewClient(, user, pass)
for client.Step(in) {
        out := client.Out()
        // send out to server
        in := serverOut
}
if client.Err() != nil {
        // auth failed
}

func NewClient

func NewClient(method *Method, user, pass string) (client *Client, err error)

NewClient returns a new SCRAM client with the provided hash algorithm.

For SCRAM-SHA-1, for example, use:

method, _ := scram.NewMethod("SCRAM-SHA-1")

client, _ := scram.NewClient(method, user, pass)

func (*Client) Close

func (c *Client) Close()

Close is a no opp to fit the saslStepper interface

func (*Client) Step

func (c *Client) Step(serverData []byte) (clientData []byte, done bool, err error)

Step progresses the underlying SASL SCRAM process

type Method

type Method struct {
	// contains filtered or unexported fields
}

Method defines the variant of SCRAM to use

func NewMethod

func NewMethod(methodString string) (*Method, error)

NewMethod returns a Method if the input method string is supported otherwise it returns an error. Supported method strings: - "SCRAM-SHA-1" - "SCRAM-SHA-256"

Jump to

Keyboard shortcuts

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