auth

package
v1.7.6 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2017 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package auth provides functions to generate and check Centrifugo tokens and signs.

Index

Constants

View Source
const (
	// AdminTokenKey is a key for admin authorization token.
	AdminTokenKey = "token"
	// AdminTokenValue is a value for secure admin authorization token.
	AdminTokenValue = "authorized"
)
View Source
const (
	HMACLength = 64
)

HMACLength used to validate length of token string we received. Centrifugo uses sha256 as digest algorithm for HMAC tokens and signs so all correct tokens must be of fixed length set by this const.

Variables

This section is empty.

Functions

func CheckAdminToken added in v1.6.0

func CheckAdminToken(secret string, token string) bool

CheckAdminToken checks admin connection token which Centrifugo returns after admin login.

func CheckApiSign

func CheckApiSign(secret string, data []byte, providedSign string) bool

CheckApiSign validates correctness of provided (in HTTP API request) sign comparing it with generated one

func CheckChannelSign

func CheckChannelSign(secret, client, channel, channelData, providedSign string) bool

CheckChannelSign validates a correctness of provided (in subscribe client command) sign comparing it with generated one

func CheckClientToken

func CheckClientToken(secret, user, timestamp, info, providedToken string) bool

CheckClientToken validates correctness of provided (by client connection) token comparing it with generated one

func GenerateAdminToken added in v1.6.0

func GenerateAdminToken(secret string) (string, error)

GenerateAdminToken generates admin authentication token.

func GenerateApiSign

func GenerateApiSign(secret string, data []byte) string

GenerateApiSign generates sign which is used to sign HTTP API requests

func GenerateChannelSign

func GenerateChannelSign(secret, client, channel, channelData string) string

GenerateChannelSign generates sign which is used to prove permission of client to subscribe on private channel

func GenerateClientToken

func GenerateClientToken(secret, user, timestamp, info string) string

GenerateClientToken generates client token based on project secret key and provided connection parameters such as user ID, timestamp and info JSON string.

Types

This section is empty.

Jump to

Keyboard shortcuts

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