-
Notifications
You must be signed in to change notification settings - Fork 798
/
token.go
39 lines (33 loc) · 1.09 KB
/
token.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Package auth provides an abstraction over claims-based security for Azure Event Hub and Service Bus.
package auth
const (
// CBSTokenTypeJWT is the type of token to be used for JWTs. For example Azure Active Directory tokens.
CBSTokenTypeJWT TokenType = "jwt"
// CBSTokenTypeSAS is the type of token to be used for SAS tokens.
CBSTokenTypeSAS TokenType = "servicebus.windows.net:sastoken"
)
type (
// TokenType represents types of tokens known for claims-based auth
TokenType string
// Token contains all of the information to negotiate authentication
Token struct {
// TokenType is the type of CBS token
TokenType TokenType
Token string
Expiry string
}
// TokenProvider abstracts the fetching of authentication tokens
TokenProvider interface {
GetToken(uri string) (*Token, error)
}
)
// NewToken constructs a new auth token
func NewToken(tokenType TokenType, token, expiry string) *Token {
return &Token{
TokenType: tokenType,
Token: token,
Expiry: expiry,
}
}