This document describes the settings required for SASL over TLS authentication in Gfarm.
There are two types of SASL authentication in Gfarm.
mech_list: the SASL authentication mechanisms to be used ...If other mechanism-specific settings are required, describe them.Multiple mechanisms can be described in mech_list, separated by spaces as follows.
For example,
mech_list: PLAIN XOAUTH2If this file is not present, all SASL mechanisms installed on the system are candidates for use.
Please refer to the Cyrus SASL documentation for configuration settings related to all mechanisms except XOAUTH2. For the XOAUTH2 mechanism, please refer to the following.
To use the XOAUTH2 mechanism, install the cyrus-sasl-xoauth2-idp package and place the following settings in the Cyrus SASL server configuration file under the name gfarm.conf.
mech_list: XOAUTH2 xoauth2_scope: scope required in JWT, used for server-side validation xoauth2_aud: audience required in JWT, used for server-side validation xoauth2_user_claim: key name of claim to be used as user ID in JWT xoauth2_group_user: a list of the user ID, the scope, and the issuer xoauth2_issuers: a list of trusted issures of JWTThe specific configuration depends on the OAuth IdP, but here is an example.
mech_list: XOAUTH2 xoauth2_scope: hpci xoauth2_aud: hpci xoauth2_user_claim: hpci.id sub|https://keycloak.example.com/auth/realms/hpci xoauth2_group_user: web_read|st.read|https://keycloak.example.com/auth/realms/hpci anon|*|* xoauth2_issuers: https://keycloak.example.com/auth/realms/hpci https://keycloak.example.org/auth/realms/hpci
Multiple scopes can be specified in `xoauth2_scope`. In that case, any one of them must be satisfied. The same applies to `xoauth2_aud`. xoauth_user_claim specifies the claim used as the username. This claim can be set per issuer. xoauth_group_user specifies a group username by defining the issuer and scope. Wildcards can be used for both issuer and scope. xoauth2_issuers specifies a list of trusted issuers. Failing to configure xoauth2_issuers will result in trusting all issuers, creating a security risk.
For more details, refer to here.
The server side accesses the IdP, but if you need to use a web proxy server for this, add the following setting:
proxy: http://PROXY-SERVER-NAME:PROXY-PORT-NUMBER/Modify "PROXY-SERVER-NAME" and "PROXY-PORT-NUMBER" as appropriate.
auth enable sasl *or
auth enable sasl_auth *Also, please add the following settings to limit the mechanisms used.
sasl_mechanisms "PLAIN XOAUTH2"For security purposes, specify only the mechanism actually used.
When the user name in SASL (SASL-username) and Gfarm (Gfarm-username) is different, register SASL user name as follows.
% gfuser -A Gfarm-username SASL SASL-username
To use ANONYMOUS mechanism, create an anonymous user in Gfarm as follows.
% gfuser -c anonymous anon / ""
sasl_mechanisms "ANONYMOUS" sasl_user "dummy-user-name"Since the anonymous mechanism configuration does not contain any user-specific information, it can also be set in gfarm2.conf.
sasl_mechanisms "PLAIN" sasl_user "USER-NAME" sasl_password "PASSWORD"
To prevent other users from reading this file, set the mode of the file to 0600 or 0400 using the chmod(1) command.
sasl_mechanisms "XOAUTH2" sasl_user "USER-NAME"
By placing the following configuration file named gfarm-client.conf in the Cyrus SASL configuration directory ($(pkg-config --variable=libdir libsasl2)/sasl2), the value in the JWT is used as the user ID. In this case, the sasl_user setting must be deleted. Additionally, you can specify the user ID via the environment variable (GFARM_SASL_USER). The priority order is GFARM_SASL_USER > sasl_user > xoauth2_user_claim.
xoauth2_user_claim: key name of claim to be used as user ID in JWTWhen specifying the user ID via the xoauth2_user_claim, user-specific configuration is unnecessary, so it is possible to configure only the sasl_mechanism setting system-wide in gfarm2.conf.
In addition, place the access token used by XOAUTH2 in the file specified by the JWT_USER_PATH environment variable, or in the file /tmp/jwt_user_u<YOUR-UNIX-UID>/token.jwt if the environment variable is not set. To prevent other users from reading this file, set the mode of the JWT file to 0600 or 0400 using the chmod(1) command.
The jwt-logon and jwt-agent commands can be used to obtain a token and set JWT in the appropriate mode for this file.
If the first character of the value set in the JWT_USER_PATH environment variable is '!', the subsequent string is treated as a command and the output of that command is used as an access token for XOAUTH2.
You can also set the JWT contents directly by using the sasl_password directive in the file specified by the GFARM_CONFIG_FILE environment variable, or in the .gfarm2rc file in your home directory if the environment variable is not set. In this case, use the chmod(1) command to set the mode of the file to 0600 or 0400 to prevent other users from reading it.