Documentation
¶
Index ¶
- type Domain
- func (d *Domain) GenerateAndSaveToken(ctx context.Context, channelID string, channelName string) (GenerateResult, error)
- func (d *Domain) GetTokens(ctx context.Context, channelName string) ([]Entry, error)
- func (d *Domain) RegenerateToken(ctx context.Context, channelID string, channelName string) (RegenerateResult, error)
- func (d *Domain) RevokeRenamedToken(ctx context.Context, channelID string, givenChannelName string, ...) (RevokeRenamedResult, error)
- func (d *Domain) RevokeToken(ctx context.Context, channelName string, givenToken string) (RevokeResult, error)
- func (d *Domain) VerifyToken(ctx context.Context, channelName string, givenToken string) (VerifyResult, error)
- type Entry
- type GenerateResult
- type RegenerateResult
- type RevokeRenamedResult
- type RevokeResult
- type Storage
- type VerifyResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Domain ¶
type Domain struct {
// contains filtered or unexported fields
}
func (*Domain) GenerateAndSaveToken ¶
func (d *Domain) GenerateAndSaveToken(ctx context.Context, channelID string, channelName string) (GenerateResult, error)
GenerateAndSaveToken returns a GenerateResult which contains secure random string as token. Then it saves the generated token to storage. This checks existing generated token in storage. If found, returns the generated token.
func (*Domain) RegenerateToken ¶
func (d *Domain) RegenerateToken(ctx context.Context, channelID string, channelName string) (RegenerateResult, error)
RegenerateToken allows generate another token for the given channel. If another token has been already generated, it returns "too many token" result. So users can have 2 tokens for each channel name maximum.
func (*Domain) RevokeRenamedToken ¶
func (d *Domain) RevokeRenamedToken(ctx context.Context, channelID string, givenChannelName string, givenToken string) (RevokeRenamedResult, error)
Revoke given token for the given channel name. If then token is not linked to another channel's id, treat as permission error.
func (*Domain) RevokeToken ¶
func (*Domain) VerifyToken ¶
func (d *Domain) VerifyToken(ctx context.Context, channelName string, givenToken string) (VerifyResult, error)
VerifyToken checks given token and existin token. It returns VerifyResult. Need to check the returned VerifyResult.NotFound and .Unmatch. Returns an error when underlying storage goes wrong.
type GenerateResult ¶
type RegenerateResult ¶
type RevokeRenamedResult ¶
type RevokeResult ¶
type RevokeResult struct {
NotFound bool
}
type Storage ¶
type Storage interface { Save(ctx context.Context, record storage.Record) error // QueryByChannelName returns found records having the same channel name. // It returns empty slice when no record found. QueryByChannelName(ctx context.Context, channelName string) ([]storage.Record, error) Delete(ctx context.Context, record storage.Record) error }