Basic, Digest, Token and Identity Authentication
RESTHeart CloudBasic Authentication
BasicAuthMechanism manages the Basic Authentication method, where the client credentials are sent via the Authorization request header using the format Authorization: Basic base64(id:pwd). The configuration allows specifying the Authenticator that will be used to verify the credentials.
basicAuthMechanism:
enabled: true
authenticator: fileRealmAuthenticator
Digest Authentication
DigestAuthMechanism manages the Digest Authentication method. The configuration allows specifying the Authenticator that will be used to verify the credentials.
digestAuthMechanism:
enabled: true
realm: RESTHeart Realm
domain: localhost
authenticator: fileRealmAuthenticator
Token Authentication
TokenBasicAuthMechanism manages the Basic Authentication method with the actual password replaced by the auth token generated by RESTHeart, i.e. the client credentials are sent via the Authorization request header using the format Authorization: Basic base64(id:auth-token). It requires a Token Manager to be configured (eg. RndTokenManager).
tokenBasicAuthMechanism:
enabled: true
Identity Authentication
IdentityAuthMechanism just authenticates any request building an BaseAccount with the username and roles specified in the configuration. Useful for testing purposes. Note that enabling this causes the DigestAuthMechanism to fail, you cannot use both.
identityAuthMechanism:
enabled: false
username: admin
roles:
- admin
- user
Avoid browsers to open the login popup window
The Basic and Digest Authentication protocols requires responding with a challenge when the request cannot be authenticated as follows:
WWW-Authenticate: Basic realm="RESTHeart Realm"
WWW-Authenticate: Digest realm="RESTHeart Realm",domain="localhost",nonce="Toez71bBUPoNMTU0NDAwNDMzNjEwMXBY+Jp7YX/GVMcxAd61FpY=",opaque="00000000000000000000000000000000",algorithm=MD5,qop="auth"
In browsers this leads to the login popup windows. In our web applications we might want to redirect to a fancy login page when the 401 Unauthorized response code.
To avoid the popup window just add to the request the noauthchallenge query parameter or the header No-Auth-Challenge. This will skip the challenge response.