im
Clone
https://git.tahinli.com/Tahinli/im.git
0 watching0 forksRustAGPL-3.0542.8 KiBb9f0726Tahinli27 days ago34 commits
| 1 | //! Checks the client-credentials tokens that family services present to `im` (contracts 2.6). |
| 2 | //! |
| 3 | //! `im` verifies its own tokens: the signature against the published keys, `iss` exactly, `aud` exactly |
| 4 | //! the string `im` (an array is refused, because `im` never issues one), `exp` and `iat`. Then the token |
| 5 | //! must be a machine token: `sub` is `client:<azp>`, `svc` names a family key, and it carries no `sid`. |
| 6 | //! The client it names must still exist, be enabled, and be registered under that family key. A user's |
| 7 | //! access token and an ID token fail one of these checks, so they never open a machine route. |
| 8 | |
| 9 | use AUTHORIZATION; |
| 10 | use jwt; |
| 11 | use is_valid_family_key; |
| 12 | use unix_now; |
| 13 | use Value; |
| 14 | use Result; |
| 15 | use Cx; |
| 16 | use StatusCode; |
| 17 | use headers; |
| 18 | use Response; |
| 19 | |
| 20 | use ; |
| 21 | use cratebearer; |
| 22 | use crate; |
| 23 | use crateAppState; |
| 24 | |
| 25 | /// The scope of the people directory, its stream and the photos (contracts 2.6 and 3). |
| 26 | pub const DIRECTORY_READ: &str = "directory.read"; |
| 27 | |
| 28 | /// The audience every directory, photo and family route requires. |
| 29 | pub const MACHINE_AUDIENCE: &str = "im"; |
| 30 | |
| 31 | /// A verified machine caller. |
| 32 | |
| 33 | |
| 34 | |
| 35 | |
| 36 | |
| 37 | |
| 38 | |
| 39 | |
| 40 | |
| 41 | |
| 42 | /// Verifies the bearer token of the request for `scope`. The outer `Result` is a server failure; the |
| 43 | /// inner one is the refusal, ready to send as the answer. |
| 44 | pub async |
| 45 | |
| 46 | |
| 47 | |
| 48 | |
| 49 | |
| 50 | |
| 51 | |
| 52 | |
| 53 | |
| 54 | |
| 55 | |
| 56 | |
| 57 | |
| 58 | |
| 59 | |
| 60 | |
| 61 | |
| 62 | |
| 63 | |
| 64 | |
| 65 | |
| 66 | |
| 67 | |
| 68 | |
| 69 | |
| 70 | |
| 71 | |
| 72 | |
| 73 | |
| 74 | |
| 75 | |
| 76 | |
| 77 | |
| 78 | |
| 79 | |
| 80 | |
| 81 | |
| 82 | |
| 83 | |
| 84 | |
| 85 | |
| 86 | |
| 87 | |
| 88 | |
| 89 | |
| 90 | |
| 91 | |
| 92 | |
| 93 | |
| 94 | |
| 95 | |
| 96 | |
| 97 | |
| 98 | |
| 99 | |
| 100 | /// `401 invalid_token`. One answer for every reason, so the reason is not disclosed. |
| 101 | |
| 102 | |
| 103 | |
| 104 | |
| 105 | |
| 106 | |
| 107 | |
| 108 |