oxide_auth/endpoint/
error.rs

1use std::error;
2use std::fmt;
3
4/// Errors which should not or need not be communicated to the requesting party but which are of
5/// interest to the server. See the documentation for each enum variant for more documentation on
6/// each as some may have an expected response. These include badly formatted headers or url encoded
7/// body, unexpected parameters, or security relevant required parameters.
8#[derive(Clone, Copy, Debug, PartialEq, Eq)]
9pub enum OAuthError {
10    /// Deny authorization to the client by essentially dropping the request.
11    ///
12    /// For example, this response is given when an incorrect client has been provided in the
13    /// authorization request in order to avoid potential indirect denial of service vulnerabilities.
14    DenySilently,
15
16    /// One of the primitives used to complete the operation failed.
17    ///
18    /// This indicates a problem in the server configuration or the frontend library or the
19    /// implementation of the primitive underlying those two.
20    PrimitiveError,
21
22    /// The incoming request was malformed.
23    ///
24    /// This implies that it did not change any internal state. Note that this differs from an
25    /// `InvalidRequest` as in the OAuth specification. `BadRequest` is reported by a frontend
26    /// implementation of a request, due to http non-compliance, while an `InvalidRequest` is a
27    /// type of response to an authorization request by a user-agent that is sent to the specified
28    /// client (although it may be caused by a bad request).
29    BadRequest,
30}
31
32impl fmt::Display for OAuthError {
33    fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> {
34        match self {
35            OAuthError::DenySilently => fmt.write_str("OAuthError: Request should be silently denied"),
36            OAuthError::PrimitiveError => fmt.write_str("OAuthError: Server component failed"),
37            OAuthError::BadRequest => fmt.write_str("OAuthError: Bad request"),
38        }
39    }
40}
41
42impl error::Error for OAuthError {}