diff --git a/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/AuthenticatedUser.java b/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/AuthenticatedUser.java index 514e65a52..b121abff4 100644 --- a/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/AuthenticatedUser.java +++ b/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/AuthenticatedUser.java @@ -28,6 +28,12 @@ package org.apache.guacamole.net.auth; */ public interface AuthenticatedUser extends Identifiable { + /** + * The identifier reserved for representing a user that has authenticated + * anonymously. + */ + public static final String ANONYMOUS_IDENTIFIER = ""; + /** * Returns the AuthenticationProvider that authenticated this user. * diff --git a/guacamole/src/main/webapp/app/auth/service/authenticationService.js b/guacamole/src/main/webapp/app/auth/service/authenticationService.js index 2bd6a9f9c..339a3e1cf 100644 --- a/guacamole/src/main/webapp/app/auth/service/authenticationService.js +++ b/guacamole/src/main/webapp/app/auth/service/authenticationService.js @@ -256,6 +256,19 @@ angular.module('auth').factory('authenticationService', ['$injector', }; + /** + * Returns whether the current user has authenticated anonymously. An + * anonymous user is denoted by the identifier reserved by the Guacamole + * extension API for anonymous users (the empty string). + * + * @returns {Boolean} + * true if the current user has authenticated anonymously, false + * otherwise. + */ + service.isAnonymous = function isAnonymous() { + return service.getCurrentUsername() === ''; + }; + /** * Returns the username of the current user. If the current user is not * logged in, this value may not be valid.