vieter/src/server/auth.v

13 lines
304 B
Coq
Raw Normal View History

2022-02-21 20:51:41 +01:00
module server
2022-01-11 21:18:33 +01:00
import net.http
// is_authorized checks whether the provided API key is correct.
2022-01-11 21:18:33 +01:00
fn (mut app App) is_authorized() bool {
x_header := app.req.header.get_custom('X-Api-Key', http.HeaderQueryConfig{ exact: true }) or {
return false
}
2022-02-21 20:40:13 +01:00
return x_header.trim_space() == app.conf.api_key
2022-01-11 21:18:33 +01:00
}