vitess.io/vitess@v0.16.2/go/vt/tableacl/acl/acl.go (about) 1 /* 2 Copyright 2019 The Vitess Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package acl 18 19 import ( 20 querypb "vitess.io/vitess/go/vt/proto/query" 21 ) 22 23 // ACL is an interface for Access Control List. 24 type ACL interface { 25 // IsMember checks the membership of a principal in this ACL. 26 IsMember(principal *querypb.VTGateCallerID) bool 27 } 28 29 // Factory is responsible to create new ACL instance. 30 type Factory interface { 31 // New creates a new ACL instance. 32 New(entries []string) (ACL, error) 33 } 34 35 // DenyAllACL implements ACL interface and always deny access request. 36 type DenyAllACL struct{} 37 38 // IsMember implements ACL.IsMember and always return false. 39 func (acl DenyAllACL) IsMember(principal *querypb.VTGateCallerID) bool { 40 return false 41 } 42 43 // AcceptAllACL implements ACL interface and always accept access request. 44 type AcceptAllACL struct{} 45 46 // IsMember implements ACL.IsMember and always return true. 47 func (acl AcceptAllACL) IsMember(principal *querypb.VTGateCallerID) bool { 48 return true 49 }