diff --git a/CHANGELOG.md b/CHANGELOG.md
index a69d694f..be2dd17f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,8 @@ For a diff between two versions https://github.com/lexik/LexikJWTAuthenticationB
## [2.0](https://github.com/lexik/LexikJWTAuthenticationBundle/tree/2.0)
+* feature [\#184](https://github.com/lexik/LexikJWTAuthenticationBundle/pull/184) [Security] Deprecate current system in favor of a JWTTokenAuthenticator (Guard) ([chalasr](https://github.com/chalasr))
+
* feature [\#218](https://github.com/lexik/LexikJWTAuthenticationBundle/pull/218) Add more flexibility in token extractors configuration ([chalasr](https://github.com/chalasr))
* feature [\#217](https://github.com/lexik/LexikJWTAuthenticationBundle/pull/217) Refactor TokenExtractors loading for easy overriding ([chalasr](https://github.com/chalasr))
@@ -25,7 +27,7 @@ For a diff between two versions https://github.com/lexik/LexikJWTAuthenticationB
## [1.7.0](https://github.com/lexik/LexikJWTAuthenticationBundle/tree/v1.7.0) (2016-08-06)
-* feature [\#200](https://github.com/lexik/LexikJWTAuthenticationBundle/pull/200) Depreciate injection of Request instances ([chalasr](https://github.com/chalasr))
+* feature [\#200](https://github.com/lexik/LexikJWTAuthenticationBundle/pull/200) Deprecate injection of Request instances ([chalasr](https://github.com/chalasr))
## [v1.6.0](https://github.com/lexik/LexikJWTAuthenticationBundle/tree/v1.6.0) (2016-07-07)
diff --git a/Encoder/DefaultEncoder.php b/Encoder/DefaultEncoder.php
index cb74718d..5ec7a9c3 100644
--- a/Encoder/DefaultEncoder.php
+++ b/Encoder/DefaultEncoder.php
@@ -57,7 +57,7 @@ public function decode($token)
}
if ($jws->isExpired()) {
- throw new JWTDecodeFailureException('Expired JWT token');
+ throw new JWTDecodeFailureException('Expired JWT Token');
}
if (!$jws->isVerified()) {
diff --git a/Encoder/JWTEncoderInterface.php b/Encoder/JWTEncoderInterface.php
index 5a21b740..140cbf73 100644
--- a/Encoder/JWTEncoderInterface.php
+++ b/Encoder/JWTEncoderInterface.php
@@ -24,7 +24,7 @@ public function encode(array $data);
/**
* @param string $token
*
- * @return false|array
+ * @return array
*
* @throws JWTDecodeFailureException If an error occurred during the loading of the token (invalid signature, expired token...)
*/
diff --git a/Exception/JWTAuthenticationException.php b/Exception/JWTAuthenticationException.php
new file mode 100644
index 00000000..9f6a376a
--- /dev/null
+++ b/Exception/JWTAuthenticationException.php
@@ -0,0 +1,69 @@
+
+ */
+class JWTAuthenticationException extends AuthenticationException
+{
+ /**
+ * Returns an AuthenticationException in case of invalid token.
+ *
+ * To be used if the token cannot be properly decoded.
+ *
+ * @param JWTDecodeFailureException|null $previous
+ *
+ * @return JWTAuthenticationException
+ */
+ public static function invalidToken(JWTDecodeFailureException $previous = null)
+ {
+ return new self($previous ? $previous->getMessage() : 'Invalid JWT Token', 0, $previous);
+ }
+
+ /**
+ * Returns an AuthenticationException in case of token not found.
+ *
+ * @param string $message
+ *
+ * @return JWTAuthenticationException
+ */
+ public static function tokenNotFound($message = 'JWT Token not found')
+ {
+ return new self($message);
+ }
+
+ /**
+ * Returns an AuthenticationException in case of invalid user.
+ *
+ * To be used if no user can be loaded from the identity retrieved from
+ * the decoded token's payload.
+ *
+ * @param string $identity
+ * @param string $identityField
+ *
+ * @return JWTAuthenticationException
+ */
+ public static function invalidUser($identity, $identityField)
+ {
+ return new self(sprintf('Unable to load a valid user with property "%s" = "%s". If the user identity has been changed, you must renew the token. Otherwise, verify that the "lexik_jwt_authentication.user_identity_field" config option is correctly set.', $identityField, $identity));
+ }
+
+ /**
+ * Returns an AuthenticationException in case of invalid payload.
+ *
+ * To be used if a key in missing in the payload or contains an unexpected value.
+ *
+ * @param string $message
+ *
+ * @return JWTAuthenticationException
+ */
+ public static function invalidPayload($message = 'Invalid payload')
+ {
+ return new self($message);
+ }
+}
diff --git a/Resources/config/services.xml b/Resources/config/services.xml
index 8a122071..06fbc641 100644
--- a/Resources/config/services.xml
+++ b/Resources/config/services.xml
@@ -18,6 +18,23 @@
%lexik_jwt_authentication.user_identity_field%
+
+
+
+ %lexik_jwt_authentication.encoder.encryption_engine%
+ %lexik_jwt_authentication.encoder.signature_algorithm%
+
+
+
+
+
+
+
+
+
+
+
+
@@ -28,6 +45,7 @@
+
%lexik_jwt_authentication.private_key_path%
@@ -40,7 +58,8 @@
%lexik_jwt_authentication.public_key_path%
%lexik_jwt_authentication.pass_phrase%
-
+
+
@@ -48,8 +67,9 @@
%lexik_jwt_authentication.user_identity_field%
+ The "%service_id%" service is deprecated since LexikJWTAuthenticationBundle version 2.0 and will be removed in 3.0
-
+
@@ -57,7 +77,11 @@
+ The "%service_id%" service is deprecated since LexikJWTAuthenticationBundle version 2.0 and will be removed in 3.0
+
+
+