Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a high level API to simplify usage #140

Closed
lcobucci opened this issue Nov 7, 2016 · 1 comment · Fixed by #759
Closed

Provide a high level API to simplify usage #140

lcobucci opened this issue Nov 7, 2016 · 1 comment · Fixed by #759

Comments

@lcobucci
Copy link
Owner

lcobucci commented Nov 7, 2016

@Ocramius gave a nice idea to help users: based on the Configuration have a really simple way to get a valid token or null from a raw token (string), something like:

function (string $tokenData) use ($configuration): ?Token {
    $parser = $configuration->getParser();
    $validator = $configuration->getValidator();
    $constraints = $configuration->getConstraints();

    try {
        $token = $parser->parse($tokenData);
    } catch (\Lcobucci\JWT\Exception $e) {
        return null;
    }

    if (!$validator->validate($token, ...$constraints) {
        return null;
    }

    return $token;
};

In order to achieve this we would need to implement #139 but also add the validation constraints in the configuration object.

@lcobucci lcobucci added this to the 4.0.0 milestone Nov 7, 2016
@lcobucci
Copy link
Owner Author

lcobucci commented Nov 7, 2016

Depends on #129 (sure)

@lcobucci lcobucci removed this from the 4.0.0 milestone Feb 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant