Count E164 authentications versus UUID authentications.
This commit is contained in:
parent
49adcca80e
commit
9faeed7b20
|
@ -28,6 +28,7 @@ public class BaseAccountAuthenticator {
|
||||||
private static final String AUTHENTICATION_SUCCEEDED_TAG_NAME = "succeeded";
|
private static final String AUTHENTICATION_SUCCEEDED_TAG_NAME = "succeeded";
|
||||||
private static final String AUTHENTICATION_FAILURE_REASON_TAG_NAME = "reason";
|
private static final String AUTHENTICATION_FAILURE_REASON_TAG_NAME = "reason";
|
||||||
private static final String AUTHENTICATION_ENABLED_REQUIRED_TAG_NAME = "enabledRequired";
|
private static final String AUTHENTICATION_ENABLED_REQUIRED_TAG_NAME = "enabledRequired";
|
||||||
|
private static final String AUTHENTICATION_CREDENTIAL_TYPE_TAG_NAME = "credentialType";
|
||||||
|
|
||||||
private static final String DAYS_SINCE_LAST_SEEN_DISTRIBUTION_NAME = name(BaseAccountAuthenticator.class, "daysSinceLastSeen");
|
private static final String DAYS_SINCE_LAST_SEEN_DISTRIBUTION_NAME = name(BaseAccountAuthenticator.class, "daysSinceLastSeen");
|
||||||
private static final String IS_PRIMARY_DEVICE_TAG = "isPrimary";
|
private static final String IS_PRIMARY_DEVICE_TAG = "isPrimary";
|
||||||
|
@ -48,11 +49,14 @@ public class BaseAccountAuthenticator {
|
||||||
public Optional<Account> authenticate(BasicCredentials basicCredentials, boolean enabledRequired) {
|
public Optional<Account> authenticate(BasicCredentials basicCredentials, boolean enabledRequired) {
|
||||||
boolean succeeded = false;
|
boolean succeeded = false;
|
||||||
String failureReason = null;
|
String failureReason = null;
|
||||||
|
String credentialType = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
AuthorizationHeader authorizationHeader = AuthorizationHeader.fromUserAndPassword(basicCredentials.getUsername(), basicCredentials.getPassword());
|
AuthorizationHeader authorizationHeader = AuthorizationHeader.fromUserAndPassword(basicCredentials.getUsername(), basicCredentials.getPassword());
|
||||||
Optional<Account> account = accountsManager.get(authorizationHeader.getIdentifier());
|
Optional<Account> account = accountsManager.get(authorizationHeader.getIdentifier());
|
||||||
|
|
||||||
|
credentialType = authorizationHeader.getIdentifier().hasNumber() ? "e164" : "uuid";
|
||||||
|
|
||||||
if (account.isEmpty()) {
|
if (account.isEmpty()) {
|
||||||
failureReason = "noSuchAccount";
|
failureReason = "noSuchAccount";
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
|
@ -97,6 +101,10 @@ public class BaseAccountAuthenticator {
|
||||||
tags = tags.and(AUTHENTICATION_FAILURE_REASON_TAG_NAME, failureReason);
|
tags = tags.and(AUTHENTICATION_FAILURE_REASON_TAG_NAME, failureReason);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (StringUtils.isNotBlank(credentialType)) {
|
||||||
|
tags = tags.and(AUTHENTICATION_CREDENTIAL_TYPE_TAG_NAME, credentialType);
|
||||||
|
}
|
||||||
|
|
||||||
Metrics.counter(AUTHENTICATION_COUNTER_NAME, tags).increment();
|
Metrics.counter(AUTHENTICATION_COUNTER_NAME, tags).increment();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue