Authentication API
Authentication API
This topic describes the web service API for user authentication.
The authentication mechanism of the ZLUX server allows for an administrator to gate access to services by a given auth handler, while on the user side the authentication structure allows for a user to login to one or more endpoints at once provided they share the same credentials given.
Handlers
The auth handlers are a type of zlux server plugin (type=nodeAuthentication) which are categorized by which kind of authentication they can provide. Whether it's to z/OS via type=saf
or theoretical authentication such as Facebook or Amazon cloud, the handler API is abstract to handle different types of security needs.
Handler installation
Auth handler plugins are installed like any other plugin.
Handler configuration
The server top-level configuration attribute dataserviceAuthentication
states properties about which plugins to use and how to use them.
For example,
"dataserviceAuthentication": {
"defaultAuthentication": "saf",
"rbac": true
}
The dataserviceAuthentication
attribute has the following properties:
- defaultAuthentication: Which authentication category to choose by default, in case multiple are installed.
- rbac: Whether or not the server should do authority checks in addition to authentication checks when requesting a dataservice.
Handler context
These plugins are given an object, context
, in the constructor.
Context has attributes to help the plugin know about the server configuration, provide a named logger, and more. The parameters include:
- pluginDefinition: The object describing the plugin's definition file
- pluginConf: An object that gives the plugin its configuration from the Config Service internal storage
- serverConfiguration: The object describing the server's current configuration
- context: An object holding contextual objects
- logger: A logger with the name of the plugin's ID
Handler capabilities
A handler's constructor should return a capabilities object that states which capabilities the plugin has. If a capabilities object is not returned, it is assumed that only the authenticate and authorize functions are implemented, for backward compatibility support. The capabilities object should include:
- canGetCategories: (true/false) If the getCategories() function exists, which returns a string array of categories of auth the plugin can support given the server context. This is useful if the plugin can support multiple categories conditionally.
- canLogout: (true/false) If the logout(request, sessionState) function exists. Used to clear state and cookies when a session should be ended.
- canGetStatus: (true/false) If the getStatus(sessionState) function exists
- canRefresh: (true/false) If the refreshStatus(request, sessionState) function exists, which is used to renew a session that has an expiration limit.
- canAuthenticate: (true/false) If the authenticate(request, sessionState):Promise function exists (Required, assumed)
- canAuthorized: (true/false) If the *authorized(request, sessionState, options) function exists (Required, assumed)
- haCompatible: (true/false) Used to be sure that a plugin has no state that would be lost in a high availibility environment.
- canGenerateHaSessionId: (true/false) If generateHaSessionId(request) exists, which is used to set the value used for an app-server session for a user. When not in a high availability environment, the app-server generates its own session ID.
- canResetPassword: (true/false) If passwordRest(request, sessionState) exists
- proxyAuthorizations: (true/false) If the addProxyAuthorizations(req1, req2Options, sessionState) function exists
Examples
sso-auth, which conditionally implements the saf, zss, and apiml security types: https://github.com/zowe/zlux-server-framework/tree/v2.x/master/plugins/sso-auth
High availability (HA)
Some auth handlers are not capable of working in a high availability environment. In these environments, there can be multiple zlux servers and there may not be a safe and secure way to share session state data. This extends to the zlux server cookie as well, which is not sharable between multiple servers by default. Therefore, high availability has the following two requirements from an auth handler plugin:
- The plugin must state that it is HA capable by setting the capability flag
haCompatible=true
, usually indicating that the plugin has no state data. - A plugin must have capability
canGenerateHaSessionId=true
so that the zlux server cookie is sharable between multiple zlux servers.
REST API
Check status
Returns the current authentication status of the user to the caller.
GET /auth
Response example:
{
"categories": {
"zss": {
"authenticated": true,
"plugins": {
"org.zowe.zlux.auth.safsso": {
"authenticated": true,
"username":"foo",
"expms": 60000
}
}
},
"zosmf": {
"authenticated": false,
"plugins": {
"org.zowe.zlux.auth.zosmf": {
"authenticated": false
}
}
}
}
}
Every key in the response object is a registered auth type. The value object is guaranteed to have a Boolean field named "authenticated" which indicates that at least one plugin in the category was able to authenticate the user.
Each item also has a field called "plugins", where every property value is a plugin-specific object.