def auth(*args, **kwargs): if not config.getboolean("authentication", "enabled"): return f(*args, **kwargs) authentication_plugin = config.get("authentication", "authentication_plugin") def authenticate(*args, **kwargs): auth = load_plugin(authentication_plugin) if auth.do(request): return f(*args, **kwargs) else: abort(403, "Access denied")
# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # @author: Juliano Martinez (ncode), Locaweb. from simplenet.common.http_utils import cache from simplenet.common.config import config from locautils.cas import CASClient, CasError cas_endpoint = config.get("authentication", "cas_endpoint") cas_sys_endpoint = config.get("authentication", "cas_sys_endpoint") cas_service = config.get("authentication", "cas_service") user_roles = get_rolesdb() class Auth(object) @cache def authenticate(self, request): cas_ticket = request.query.get("ticket") if not cas_ticket: abort(403, "Null Authentication Ticket (CAS)") try: logger.info("Trying to validate CAS ticket '%s' on server '%s'" % (cas_ticket, servers[0])) user_info = CASClient(server=servers[0]).validate_ticket(ticket=cas_ticket, service=service) except CasError:
self.owner_id = owner_id def to_dict(self): return { 'id': self.id, 'owner_id': self.owner_id, 'proto': self.proto, 'src': self.src, 'src_port': self.src_port, 'dst': self.dst, 'dst_port': self.dst_port, 'table': self.table, 'policy': self.policy, 'owner': self.ip.ip } database_type = config.get('server', 'database_type') database_name = config.get('server', 'database_name') engine = None if 'sqlite' in database_type: def _fk_pragma_on_connect(dbapi_con, con_record): dbapi_con.execute('pragma foreign_keys=ON') engine = create_engine('%s:///%s' % (database_type, database_name)) event.listen(engine, 'connect', _fk_pragma_on_connect) else: database_user = config.get('server', 'database_user') database_pass = config.get('server', 'database_pass') database_host = config.get('server', 'database_host') engine = create_engine("%s://%s:%s@%s/%s" % (database_type, database_user,
def __init__(self): self.url = config.get("event", "broker")