<commit_before><?php

namespace Northstar\Auth;

use League\OAuth2\Server\Exception\OAuthServerException;
use Northstar\Models\Client;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;

class Scope
{
    /**
     * Available API Key scopes.
     * @var array
     */
    protected static $scopes = [
        'role:admin' => [
            'description' => 'Allows this client to act as an administrator if the user has that role.',
        ],
        'role:staff' => [
            'description' => 'Allows this client to act as a staff member if the user has that role.',
        ],
        'admin' => [
            'description' => 'Grant administrative privileges to this token, whether or not the user has the admin role.',
            'warning' => true,
        ],
        'user' => [
            'description' => 'Allows actions to be made on a user\'s behalf.',
        ],
        'profile' => [
            'description' => 'Allows viewing an authenticated user\'s full profile.',
        ],
        'email' => [
            'description' => 'Allows viewing the authenticated user\'s email address.',
        ],
        'openid' => [
            'description' => 'Allows users to be authorized by OpenID Connect.',
        ],
        'client' => [
            'description' => 'Allows access to the client resource.',
        ],
        'activity' => [
            'description' => 'Allows access to user activity.',
        ],
        'write' => [
            'description' => 'Allows access to create/update/delete endpoints.',
        ],
    ];

    /**
     * Return a list of all scopes & their descriptions.
     *
     * @return array
     */
    public static function all()
    {
        return static::$scopes;
    }

    /**
     * Validate if all the given scopes are valid.
     *
     * @param $scopes
     * @return bool
     */
    public static function validateScopes($scopes)
    {
        if (! is_array($scopes)) {
            return false;
        }

        return ! array_diff($scopes, array_keys(static::$scopes));
    }

    /**
     * Return whether the current request includes the proper client scopes.<commit_msg>Update scope descriptions.<commit_after><?php

namespace Northstar\Auth;

use League\OAuth2\Server\Exception\OAuthServerException;
use Northstar\Models\Client;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;

class Scope
{
    /**
     * Available API Key scopes.
     * @var array
     */
    protected static $scopes = [
        'role:admin' => [
            'description' => 'Allows application to use a admin user\'s permissions.',
        ],
        'role:staff' => [
            'description' => 'Allows application to use a staff user\'s permissions.',
        ],
        'admin' => [
            'description' => 'Grant administrative privileges to this token, whether or not the user has the admin role.',
            'hint' => 'Careful, don\'t use this scope with Authorization Code clients!',
        ],
        'user' => [
            'description' => 'Allows access to the user resource.',
        ],
        'client' => [
            'description' => 'Allows access to the client resource.',
            'hint' => 'Be sure you need this scope before assigning! This allows your app to read other OAuth client secrets, so a leaked key is extra dangerous.',
        ],
        'activity' => [
            'description' => 'Allows access to user activity resources (signups, posts, etc.) in Rogue.',
        ],
        'write' => [
            'description' => 'Allows access to create/update/delete endpoints.',
        ],
        'profile' => [
            'description' => 'Some third-party implementations may request this scope.',
        ],
        'email' => [
            'description' => 'Some third-party implementations may request this scope.',
        ],
        'openid' => [
            'description' => 'Some third-party implementations may request this scope.',
        ],
    ];

    /**
     * Return a list of all scopes & their descriptions.
     *
     * @return array
     */
    public static function all()
    {
        return static::$scopes;
    }

    /**
     * Validate if all the given scopes are valid.
     *
     * @param $scopes
     * @return bool
     */
    public static function validateScopes($scopes)
    {
        if (! is_array($scopes)) {
            return false;
        }

        return ! array_diff($scopes, array_keys(static::$scopes));
    }

    /**
     * Return whether the current request includes the proper client scopes.
{'fraction_non_alphanumeric': 0.11981667394151026, 'fraction_numerical': 0.00043649061545176777, 'mean_word_length': 1.9856677524429966, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 46, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1258084', 'n_tokens_mistral': 1211, 'n_tokens_neox': 1215, 'n_words': 388}