mirror of
https://github.com/anyproto/any-sync.git
synced 2025-06-08 14:07:02 +09:00
30 lines
693 B
Go
30 lines
693 B
Go
package secureservice
|
|
|
|
import "context"
|
|
|
|
type ctxKey int
|
|
|
|
const (
|
|
allowAccountCheck ctxKey = iota
|
|
)
|
|
|
|
type configGetter interface {
|
|
GetSecureService() Config
|
|
}
|
|
|
|
type Config struct {
|
|
RequireClientAuth bool `yaml:"requireClientAuth"`
|
|
}
|
|
|
|
// CtxAllowAccountCheck upgrades the context to allow identity check on handshake
|
|
func CtxAllowAccountCheck(ctx context.Context) context.Context {
|
|
return context.WithValue(ctx, allowAccountCheck, true)
|
|
}
|
|
|
|
// CtxIsAccountCheckAllowed checks if the "allowAccountCheck" flag is set to true in the provided context.
|
|
func CtxIsAccountCheckAllowed(ctx context.Context) bool {
|
|
if v, ok := ctx.Value(allowAccountCheck).(bool); ok {
|
|
return v
|
|
}
|
|
return false
|
|
}
|