hotime/vendor/github.com/xdg-go/scram
2022-10-19 21:32:34 +08:00
..
.gitignore 升级流程引擎配置文件版本 2022-10-19 21:32:34 +08:00
CHANGELOG.md 升级流程引擎配置文件版本 2022-10-19 21:32:34 +08:00
client_conv.go 升级流程引擎配置文件版本 2022-10-19 21:32:34 +08:00
client.go 升级流程引擎配置文件版本 2022-10-19 21:32:34 +08:00
common.go 升级流程引擎配置文件版本 2022-10-19 21:32:34 +08:00
doc.go 升级流程引擎配置文件版本 2022-10-19 21:32:34 +08:00
go.mod 升级流程引擎配置文件版本 2022-10-19 21:32:34 +08:00
go.sum 升级流程引擎配置文件版本 2022-10-19 21:32:34 +08:00
LICENSE 升级流程引擎配置文件版本 2022-10-19 21:32:34 +08:00
parse.go 升级流程引擎配置文件版本 2022-10-19 21:32:34 +08:00
README.md 升级流程引擎配置文件版本 2022-10-19 21:32:34 +08:00
scram.go 升级流程引擎配置文件版本 2022-10-19 21:32:34 +08:00
server_conv.go 升级流程引擎配置文件版本 2022-10-19 21:32:34 +08:00
server.go 升级流程引擎配置文件版本 2022-10-19 21:32:34 +08:00

Go Reference Go Report Card Github Actions

scram  Go implementation of RFC-5802

Description

Package scram provides client and server implementations of the Salted Challenge Response Authentication Mechanism (SCRAM) described in RFC-5802 and RFC-7677.

It includes both client and server side support.

Channel binding and extensions are not (yet) supported.

Examples

Client side

package main

import "github.com/xdg-go/scram"

func main() {
    // Get Client with username, password and (optional) authorization ID.
    clientSHA1, err := scram.SHA1.NewClient("mulder", "trustno1", "")
    if err != nil {
        panic(err)
    }

    // Prepare the authentication conversation. Use the empty string as the
    // initial server message argument to start the conversation.
    conv := clientSHA1.NewConversation()
    var serverMsg string

    // Get the first message, send it and read the response.
    firstMsg, err := conv.Step(serverMsg)
    if err != nil {
        panic(err)
    }
    serverMsg = sendClientMsg(firstMsg)

    // Get the second message, send it, and read the response.
    secondMsg, err := conv.Step(serverMsg)
    if err != nil {
        panic(err)
    }
    serverMsg = sendClientMsg(secondMsg)

    // Validate the server's final message.  We have no further message to
    // send so ignore that return value.
    _, err = conv.Step(serverMsg)
    if err != nil {
        panic(err)
    }

    return
}

func sendClientMsg(s string) string {
    // A real implementation would send this to a server and read a reply.
    return ""
}

Copyright 2018 by David A. Golden. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"). You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0