appservice: Rename verify_hs_token to hs_token_matches
parent
325531d13f
commit
14bc4eb7e0
|
@ -65,7 +65,7 @@ async fn push_transactions(
|
||||||
request: IncomingRequest<api::event::push_events::v1::IncomingRequest>,
|
request: IncomingRequest<api::event::push_events::v1::IncomingRequest>,
|
||||||
appservice: Data<Appservice>,
|
appservice: Data<Appservice>,
|
||||||
) -> Result<HttpResponse, Error> {
|
) -> Result<HttpResponse, Error> {
|
||||||
if !appservice.verify_hs_token(request.access_token) {
|
if !appservice.hs_token_matches(request.access_token) {
|
||||||
return Ok(HttpResponse::Unauthorized().finish());
|
return Ok(HttpResponse::Unauthorized().finish());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ async fn query_user_id(
|
||||||
request: IncomingRequest<api::query::query_user_id::v1::IncomingRequest>,
|
request: IncomingRequest<api::query::query_user_id::v1::IncomingRequest>,
|
||||||
appservice: Data<Appservice>,
|
appservice: Data<Appservice>,
|
||||||
) -> Result<HttpResponse, Error> {
|
) -> Result<HttpResponse, Error> {
|
||||||
if !appservice.verify_hs_token(request.access_token) {
|
if !appservice.hs_token_matches(request.access_token) {
|
||||||
return Ok(HttpResponse::Unauthorized().finish());
|
return Ok(HttpResponse::Unauthorized().finish());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ async fn query_room_alias(
|
||||||
request: IncomingRequest<api::query::query_room_alias::v1::IncomingRequest>,
|
request: IncomingRequest<api::query::query_room_alias::v1::IncomingRequest>,
|
||||||
appservice: Data<Appservice>,
|
appservice: Data<Appservice>,
|
||||||
) -> Result<HttpResponse, Error> {
|
) -> Result<HttpResponse, Error> {
|
||||||
if !appservice.verify_hs_token(request.access_token) {
|
if !appservice.hs_token_matches(request.access_token) {
|
||||||
return Ok(HttpResponse::Unauthorized().finish());
|
return Ok(HttpResponse::Unauthorized().finish());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -272,7 +272,7 @@ impl Appservice {
|
||||||
/// Compare the given `hs_token` against `registration.hs_token`
|
/// Compare the given `hs_token` against `registration.hs_token`
|
||||||
///
|
///
|
||||||
/// Returns `true` if the tokens match, `false` otherwise.
|
/// Returns `true` if the tokens match, `false` otherwise.
|
||||||
pub fn verify_hs_token(&self, hs_token: impl AsRef<str>) -> bool {
|
pub fn hs_token_matches(&self, hs_token: impl AsRef<str>) -> bool {
|
||||||
self.registration.hs_token == hs_token.as_ref()
|
self.registration.hs_token == hs_token.as_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -119,7 +119,7 @@ async fn test_verify_hs_token() -> Result<()> {
|
||||||
|
|
||||||
let registration = appservice.registration();
|
let registration = appservice.registration();
|
||||||
|
|
||||||
assert!(appservice.verify_hs_token(®istration.hs_token));
|
assert!(appservice.hs_token_matches(®istration.hs_token));
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue