@@ -100,11 +100,17 @@ impl<'a, 'r> FromRequest<'a, 'r> for DeletionAuth {
100
100
type Error = ApiKeyError ;
101
101
102
102
fn from_request ( request : & ' a Request < ' r > ) -> request:: Outcome < Self , Self :: Error > {
103
- let auth = match request. headers ( ) . get_one ( "Authorization" ) {
103
+ let header = request
104
+ . headers ( )
105
+ . iter ( )
106
+ . filter ( |h| h. name == "Authorization" )
107
+ . map ( |h| h. value . to_lowercase ( ) )
108
+ . find ( |h| h. starts_with ( "key " ) ) ;
109
+ let auth = match header {
104
110
Some ( a) => a,
105
111
None => return Outcome :: Failure ( ( HttpStatus :: BadRequest , ApiKeyError :: NotPresent ) ) ,
106
112
} ;
107
- if !auth. to_lowercase ( ) . starts_with ( "key " ) {
113
+ if !auth. starts_with ( "key " ) {
108
114
return Outcome :: Failure ( ( HttpStatus :: BadRequest , ApiKeyError :: BadHeader ) ) ;
109
115
}
110
116
let uuid = match Uuid :: from_str ( & auth[ 4 ..] ) {
@@ -148,11 +154,17 @@ impl<'a, 'r> FromRequest<'a, 'r> for RequiredUser {
148
154
type Error = ApiKeyError ;
149
155
150
156
fn from_request ( request : & ' a Request < ' r > ) -> request:: Outcome < Self , Self :: Error > {
151
- let auth = match request. headers ( ) . get_one ( "Authorization" ) {
157
+ let header = request
158
+ . headers ( )
159
+ . iter ( )
160
+ . filter ( |h| h. name == "Authorization" )
161
+ . map ( |h| h. value . to_lowercase ( ) )
162
+ . find ( |h| h. starts_with ( "key " ) ) ;
163
+ let auth = match header {
152
164
Some ( a) => a,
153
165
None => return Outcome :: Failure ( ( HttpStatus :: BadRequest , ApiKeyError :: NotPresent ) ) ,
154
166
} ;
155
- if !auth. to_lowercase ( ) . starts_with ( "key " ) {
167
+ if !auth. starts_with ( "key " ) {
156
168
return Outcome :: Failure ( ( HttpStatus :: BadRequest , ApiKeyError :: BadHeader ) ) ;
157
169
}
158
170
let uuid = match Uuid :: from_str ( & auth[ 4 ..] ) {
@@ -194,11 +206,17 @@ impl<'a, 'r> FromRequest<'a, 'r> for OptionalUser {
194
206
type Error = ApiKeyError ;
195
207
196
208
fn from_request ( request : & ' a Request < ' r > ) -> request:: Outcome < Self , Self :: Error > {
197
- let auth = match request. headers ( ) . get_one ( "Authorization" ) {
209
+ let header = request
210
+ . headers ( )
211
+ . iter ( )
212
+ . filter ( |h| h. name == "Authorization" )
213
+ . map ( |h| h. value . to_lowercase ( ) )
214
+ . find ( |h| h. starts_with ( "key " ) ) ;
215
+ let auth = match header {
198
216
Some ( a) => a,
199
217
None => return Outcome :: Success ( OptionalUser ( None ) ) ,
200
218
} ;
201
- if !auth. to_lowercase ( ) . starts_with ( "key " ) {
219
+ if !auth. starts_with ( "key " ) {
202
220
return Outcome :: Failure ( ( HttpStatus :: BadRequest , ApiKeyError :: BadHeader ) ) ;
203
221
}
204
222
let uuid = match Uuid :: from_str ( & auth[ 4 ..] ) {
0 commit comments