Determine if a user is allowed to view this route.
18152
def before_request(self) -> Optional[Response]:
        """"""
        auth = request.authorization
        if not auth or not self._check_auth(auth.username, auth.password):
            return Response(
                'Could not verify your access level for that URL.\n'
                'You have to login with proper credentials', 401,
                {'WWW-Authenticate': 'Basic realm="Login Required"'}
            )
        session['logged_in'] = auth.username
        # pylint wants this return statement
        return None
1094072
public static function checkRoute($route, $params = [], $user = null)
    {
        $config = Configs::instance();
        $r = static::normalizeRoute($route, $config->advanced);
        if ($config->onlyRegisteredRoute && !isset(static::getRegisteredRoutes()[$r])) {
            return true;
        }

        if ($user === null) {
            $user = Yii::$app->getUser();
        }
        $userId = $user instanceof User ? $user->getId() : $user;

        if ($config->strict) {
            if ($user->can($r, $params)) {
                return true;
            }
            while (($pos = strrpos($r, '/')) > 0) {
                $r = substr($r, 0, $pos);
                if ($user->can($r . '/*', $params)) {
                    return true;
                }
            }
            return $user->can('/*', $params);
        } else {
            $routes = static::getRoutesByUser($userId);
            if (isset($routes[$r])) {
                return true;
            }
            while (($pos = strrpos($r, '/')) > 0) {
                $r = substr($r, 0, $pos);
                if (isset($routes[$r . '/*'])) {
                    return true;
                }
            }
            return isset($routes['/*']);
        }
    }
908500
function allowRoute (args) {
    // validate args
    this.requireValidArgsRoute(args)
    // start new audit
    this.newAudit(args, 'route')
    // get access rules
    var rules = this.getRules('route')
    // if no rules exist for model then default to allow
    if (!rules) {
        return this.audit.setAllow(true)
    }
    // get path
    var path = args.path
    // if path ends in / append index
    if (path.charAt(path.length - 1) === '/') {
        path = path + 'index';
    }
    // split path into segments
    var segments = path.split('/')
    // discard first empty segment of path
    segments.shift()
    // get roles from session or use defaults
    var roles = this.getRoles(args.session)
    // default to allow
    var allow = true
    // check global rules
    if (rules.allow) {
        allow = this.isRoleAllowed(allow, roles, rules.allow, false, 'global')
    }
    // get number of segments
    var segmentsLen = segments.length
    // check each path segment to see if it has any rules
    for (var i=0; i<segmentsLen; i++) {
        // get next segment
        var segment = segments[i]
        // get rules for path segment if any
        rules = rules.path && rules.path[segment]
        // if there are rules check them
        if (rules) {
            // set to true if segment has any rules
            var hasRules = false
            // if there are rules that apply to all methods check them
            if (rules.allow) {
                allow = this.isRoleAllowed(allow, roles, rules.allow, false, 'path', {
                    segment: segment,
                })
                hasRules = true
            }
            // if there is a method specific rule for route that matches
            // the method being requested then check it - this overrides
            // any non method specific rule
            if (rules.method && rules.method[args.method]) {
                allow = this.isRoleAllowed(allow, roles, rules.method[args.method].allow, false, 'method', {
                    segment: segment,
                })
                hasRules = true
            }
            // if segment has no rules then add audit record to indicate this
            if (!hasRules) {
                this.audit.setRule({
                    ruleType: 'none',
                    segment: segment,
                })
            }
        }
        // if there are no rules for this segment then there can be not rules
        // for any child segment so return current allow status
        else {
            return this.audit.setAllow(allow)
        }
    }

    return this.audit.setAllow(allow)
}
929044
def has_permission_to_view(page, user):
    
    if page.permissions.count() == 0:
        return True
    for perm in page.permissions.all():
        perm_label = '%s.%s' % (perm.content_type.app_label, perm.codename)
        if user.has_perm(perm_label):
            return True
    return False
1209190
def check_permissions(self, request):
        """"""

        if not self.predicates:
            return True

        # All registered authentication predicates must return True
        return all(
            predicate(request, *self.predicates_params[i])
            for i, predicate in enumerate(self.predicates)
        )
696678
function checkAccessRights(req, res, next) {
	const uri = (typeof req.contextPath === "string" && req.baseUrl.substring(req.contextPath.length)) || req.baseUrl;
	req.user.checkRights(req.user.username, uri, req, res, next);
}
883381
def has_access(self, permission_name, view_name):
        
        if current_user.is_authenticated:
            return self._has_view_access(g.user, permission_name, view_name)
        elif current_user_jwt:
            return self._has_view_access(current_user_jwt, permission_name, view_name)
        else:
            return self.is_item_public(permission_name, view_name)
528608
def has_read_permission(self, request, path):
        
        user = request.user
        if not user.is_authenticated():
            return False
        elif user.is_superuser:
            return True
        elif user.is_staff:
            return True
        else:
            return False
1268871
def accessible_to(self, user):
        
        if user.is_superuser:
            try:
                queryset = self.get_queryset()
            except AttributeError:
                queryset = self
        elif user.is_authenticated():
            # get user group (higher id)
            group = user.groups.all().order_by('-id')[0]
            queryset = self.filter(access_level__lte=ACCESS_LEVELS.get(group.name))
        else:
            queryset = self.filter(access_level__lte=ACCESS_LEVELS.get('public'))
        return queryset
5101
def can_view(self, user):
        """"""
        return user.is_admin or self == user \
            or set(self.classes).intersection(user.admin_for)
1046801
def users_view_user(self, ):
        
        i = self.users_tablev.currentIndex()
        item = i.internalPointer()
        if item:
            user = item.internal_data()
            self.view_user(user)
1359463
public function canView($member = null) {
		if(!$member) $member = Member::currentUser();

		if(Permission::checkMember($member, 'ADMIN')) return true;

		return $member->inGroups($this->Viewers());
	}
443161
public boolean allowAccess(String user) {

        try {
            return m_cms.getPermissions(m_root, user).requiresViewPermission();
        } catch (CmsException e) {
            LOG.error(e.getLocalizedMessage(), e);
            return true;
        }
    }
885442
function isWhitelisted(url) {
		return options.adiPathFilter.some(function (route) {
			return url.substr(0, route.length) === route;
		});
	}
1089404
def has_permission(self, request, view):
        
        url_username = request.parser_context.get('kwargs', {}).get('username', '')
        if request.user.username.lower() != url_username.lower():
            if request.user.is_staff:
                return False  # staff gets 403
            raise Http404()
        return True
793403
public function canView($member = null)
    {
        //get member
        if (!$member) {
            $member = Security::getCurrentUser();
        }
        //check for extensions, we do this first as they can overrule everything
        $extended = $this->extendedCan(__FUNCTION__, $member);
        if ($extended !== null) {
            return $extended;
        }

        //need to be logged in and/or most checks below rely on $member being a Member
        if (!$member) {
            return false;
        }
        // members can usually view their own record
        if ($this->ID == $member->ID) {
            return true;
        }

        //standard check
        return Permission::checkMember($member, 'CMS_ACCESS_SecurityAdmin');
    }
784586
def can_read(self):
        
        sm = getSecurityManager()
        if not sm.checkPermission(permissions.View, self.context):
            return False
        return True