1
0
mirror of https://github.com/matrix-org/matrix-authentication-service.git synced 2025-07-09 10:01:45 +03:00

Make PKCE implementation compliant with RFC7636

This checks for the PKCE code_verifier length as well as the characters
used. It also give better errors when the PKCE verifier is invalid.

Fixes #316
This commit is contained in:
Quentin Gliech
2022-08-01 20:18:43 +02:00
parent 23360bc233
commit 372b32a780
5 changed files with 62 additions and 12 deletions

View File

@ -12,10 +12,12 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#[derive(serde::Serialize)]
use std::borrow::Cow;
#[derive(serde::Serialize, Clone)]
pub struct ClientError {
pub error: &'static str,
pub error_description: &'static str,
pub error_description: Cow<'static, str>,
}
impl ClientError {
@ -23,7 +25,15 @@ impl ClientError {
pub const fn new(error: &'static str, error_description: &'static str) -> Self {
Self {
error,
error_description,
error_description: Cow::Borrowed(error_description),
}
}
#[must_use]
pub const fn with_description(&self, description: String) -> Self {
Self {
error: self.error,
error_description: Cow::Owned(description),
}
}
}