im
Clone
https://git.tahinli.com/Tahinli/im.git
0 watching0 forksRustAGPL-3.0542.8 KiBb9f0726Tahinli27 days ago34 commits
| 1 | //! The OAuth 2.0 and OpenID Connect rules that are pure text: the scope names, the URI rules of |
| 2 | //! registered clients, the family-key format, and PKCE (RFC 7636). |
| 3 | //! |
| 4 | //! Nothing here touches the database or the network. The registration command and the endpoints use |
| 5 | //! the same functions, so a value is accepted or refused the same way everywhere. |
| 6 | |
| 7 | use ; |
| 8 | use ; |
| 9 | |
| 10 | /// Scopes a person grants at sign-in. Every family client is first-party, so there is no consent screen. |
| 11 | pub const USER_SCOPES: = ; |
| 12 | |
| 13 | /// Every scope the provider advertises (contracts section 2.1). |
| 14 | pub const SUPPORTED_SCOPES: = |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 | ; |
| 21 | |
| 22 | /// The longest `state` or `nonce` accepted, in bytes. Longer values are refused, not truncated. |
| 23 | pub const MAX_ECHO_BYTES: usize = 512; |
| 24 | |
| 25 | /// The longest registered URI, in bytes. |
| 26 | pub const MAX_URI_BYTES: usize = 2048; |
| 27 | |
| 28 | /// True for a scope the provider knows. |
| 29 | |
| 30 | |
| 31 | |
| 32 | |
| 33 | /// True for a scope a person can be granted at sign-in. |
| 34 | |
| 35 | |
| 36 | |
| 37 | |
| 38 | /// The S256 code challenge of a verifier: base64url of its SHA-256, without padding. |
| 39 | |
| 40 | |
| 41 | |
| 42 | |
| 43 | /// True for a code challenge: exactly 43 base64url characters (32 bytes, unpadded). |
| 44 | |
| 45 | |
| 46 | |
| 47 | |
| 48 | |
| 49 | |
| 50 | |
| 51 | /// True for a code verifier: 43 to 128 unreserved characters (RFC 7636 section 4.1). |
| 52 | |
| 53 | |
| 54 | |
| 55 | |
| 56 | |
| 57 | |
| 58 | |
| 59 | /// True for a registrable URI: `https`, or `http` to a loopback host (for development), absolute, with |
| 60 | /// no fragment, no userinfo (`@`), no whitespace or control characters and no backslash. A registered URI |
| 61 | /// is ASCII only: a Unicode character, such as a bidi override, could show the URI differently from how it |
| 62 | /// is stored, so other bytes must be percent-encoded. Redirect URIs, post-logout URIs and back-channel URIs |
| 63 | /// all use this rule. |
| 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 | /// The host of an authority (`host`, `host:port`, `[v6]:port`). |
| 94 | |
| 95 | |
| 96 | |
| 97 | |
| 98 | |
| 99 | |
| 100 | |
| 101 | |
| 102 | |
| 103 | |
| 104 | |
| 105 | /// The family key of im's own switcher row. No client may carry it, so a family app can never take the |
| 106 | /// row that names this service. |
| 107 | pub const HOME_KEY: &str = "im"; |
| 108 | |
| 109 | /// True for a family key: `^[a-z][a-z0-9-]{0,31}$`, the same rule as `services.key`. |
| 110 | |
| 111 | |
| 112 | |
| 113 | |
| 114 | |
| 115 | |
| 116 | |
| 117 | |
| 118 | |
| 119 | /// True for a family key a client may carry: a valid family key other than [`HOME_KEY`]. The admin page and |
| 120 | /// `im client add` both use this, so the reserved key is refused the same way everywhere. |
| 121 | |
| 122 | |
| 123 | |
| 124 | |
| 125 | |
| 126 | |
| 127 | |
| 128 | |
| 129 | |
| 130 | |
| 131 | |
| 132 | |
| 133 | |
| 134 | |
| 135 | |
| 136 | |
| 137 | |
| 138 | |
| 139 | |
| 140 | |
| 141 | |
| 142 | |
| 143 | |
| 144 | |
| 145 | |
| 146 | |
| 147 | |
| 148 | |
| 149 | |
| 150 | |
| 151 | |
| 152 | |
| 153 | |
| 154 | |
| 155 | |
| 156 | |
| 157 | |
| 158 | |
| 159 | |
| 160 | |
| 161 | |
| 162 | |
| 163 | |
| 164 |