docs/en/best_practices/authentication_authorization.md
import AuthConcept from '../_assets/best_practices/auth_concept.mdx' import AuthFeature from '../_assets/best_practices/auth_feature.mdx' import AuthSeeAlso from '../_assets/best_practices/auth_see_also.mdx'
This topic aims to provide a coherent guide for best practices on developing your own authentication and authorization workflow.
For detailed instructions on each operation involved below, see links in See Also.
Large enterprises often have complex organizational structures and a vast number of employees using diverse platforms and tools. From an IT governance perspective, having a unified identity, authentication, and authorization system brings significant advantages:
Suppose that three new employees join different departments of a SaaS company: one Marketing Specialist and two Solution Architects.
Although all three use the same identity provider, their access rights are strictly enforced:
This example highlights the three key components in an enterprise identity and access flow:
These layers of access control also apply to the database system:
As you can see, authentication and authorization are tightly coupled in practice. A user's authentication request often implies a broader access control requirement. Therefore, it is essential to understand the full access flow.
Lightweight Directory Access Protocol (LDAP) is a protocol for accessing and maintaining distributed directory information. You can think of it as your organization’s global address book:
ldapsearch queries can retrieve users or groups.LDAP can be used:
The system supports all three layers of access control:
From v3.5 onward, StarRocks provides a modular, composable model to support various combinations of identity and access management components.
Feature Mapping
<AuthFeature />Comparison of supported authentication modes:
| Method | CREATE USER (Native user) | CREATE SECURITY INTEGRATION (Session-based dummy user) |
|---|---|---|
| Description | Manually creates users in the cluster. You can associate them with external authentication systems. The user exists explicitly in the cluster. | Defines an external authentication integration. The cluster does not store any user information. You can optionally combine it with a Group Provider to define allowed users. |
| Login Process | Users must be pre-created in the cluster. During login, the user is authenticated via StarRocks or via the configured external authentication system (for example, LDAP). Only pre-created users can log in. | Upon login, StarRocks authenticates the user using external identity systems. If succeeds, it creates a temporary, session-scoped "dummy user" internally. This user is discarded after the session ends. |
| Authorization Process | Since users exist in the cluster, permissions can be assigned in advance using either the native authorization system or Apache Ranger. | Although users do not persist, you can predefine role-to-group mappings. When a user logs in, the system assigns roles based on their group, enabling RBAC. Apache Ranger can also be used in parallel. |
| Pros & Cons, Use Cases | <ul><li>Pros: Full flexibility—supports both native and external authorization systems.</li><li>Cons: Requires manual effort for creating users, which can be cumbersome.</li><li>Recommended for: Small user bases or cases where the cluster handles access control.</li></ul> | <ul><li>Pros: Easy to set up; only requires external authentication configuration and allowed group definitions.</li><li>Recommended for: Ideal for large user bases with role-group mappings.</li></ul> |
These authentication modes can coexist. When a user attempts to log in:
authentication_chain as defined in the configuration.This hybrid mode provides both flexibility and control, suitable for different organizational requirements.
For example, you can use the following syntax to create a native user with LDAP:
CREATE USER <username> IDENTIFIED WITH authentication_ldap_simple AS 'uid=tom,ou=company,dc=example,dc=com';
Then, you can GRANT privileges or roles to the user, or delegate authorization to external systems like Apache Ranger.
You can also create a security integration to allow access of your external authentication service to the cluster.
CREATE SECURITY INTEGRATION <security_integration_name>
PROPERTIES (
"type" = "authentication_ldap_simple",
"authentication_ldap_simple_server_host" = "",
"authentication_ldap_simple_server_port" = "",
"authentication_ldap_simple_bind_base_dn" = "",
"authentication_ldap_simple_user_search_attr" = ""
"authentication_ldap_simple_bind_root_dn" = "",
"authentication_ldap_simple_bind_root_pwd" = "",
"authentication_ldap_simple_ssl_conn_allow_insecure" = "{true | false}",
"authentication_ldap_simple_ssl_conn_trust_store_path" = "",
"authentication_ldap_simple_ssl_conn_trust_store_pwd" = "",
"comment" = ""
);
After that, you need to configure the FE parameter authentication_chain and enable the security integration for your cluster.
ADMIN SET FRONTEND CONFIG (
"authentication_chain" = "<security_integration_name>[... ,]"
);
Group information in the cluster is decoupled from both the authentication and authorization systems. It serves as a shared layer that can be independently configured and then used across both login control and access control.
Authentication Stage
When used together with a security integration, group membership can define the scope of who is allowed to log in. Only users who pass authentication and belong to a specified group will be allowed to access the cluster.
Authorization Stage
Group membership is automatically taken into account during authorization. If privileges are granted to a group, all users within that group will inherit the permissions during access checks.
The following example is based on LDAP.
Create a group provider.
-- LDAP Group Provider
CREATE GROUP PROVIDER <group_provider_name>
PROPERTIES (
"type" = "ldap",
ldap_info,
ldap_search_group_arg,
ldap_search_attr,
[ldap_cache_attr]
)
ldap_info ::=
"ldap_conn_url" = "",
"ldap_bind_root_dn" = "",
"ldap_bind_root_pwd" = "",
"ldap_bind_base_dn" = "",
["ldap_conn_timeout" = "",]
["ldap_conn_read_timeout" = ""]
ldap_search_group_arg ::=
{ "ldap_group_dn" = ""
| "ldap_group_filter" = "" },
"ldap_group_identifier_attr" = ""
ldap_search_user_arg ::=
"ldap_group_member_attr" = "",
"ldap_user_search_attr" = ""
ldap_cache_arg ::=
"ldap_cache_refresh_interval" = ""
Integrate the group provider with a security integration.
ALTER SECURITY INTEGRATION <security_integration_name> SET
(
"group_provider" = "",
"permitted_groups" = ""
)
Integrate the group provider with the authorization system. You can use either the native authorization or Apache Ranger.
Native authorization:
Roles can be assigned to groups. On login, users are automatically assigned roles based on group membership.
GRANT role TO EXTERNAL GROUP <group_name>
Apache Ranger:
Once a user logs in, StarRocks passes group information to Ranger for policy evaluation.
StarRocks supports both internal and external authorization mechanisms, which can be used independently or in combination:
Internal Authorization
StarRocks provides a built-in RBAC (Role-Based Access Control) and IBAC (Identity-Based Access Control) system.
External Authorization
StarRocks integrates with Apache Ranger to support centralized and unified authorization management.
Apache Ranger can be used either as an integral solution itself or together with StarRocks' native authorization system.
This flexibility allows organizations to gradually migrate to centralized authorization or maintain a hybrid model that fits their current infrastructure and security policies.
You can choose the solution based on how you want to finish your authentication and authorization workflow.
You can fully leverage the external authentication and authorization systems to control login and access permissions for the cluster. The overall process is as follows:
:::note
You must ensure that user IDs and group names remain consistent across all integrated systems throughout this process.
:::
If you prefer to use the built-in authorization system while still relying on external authentication, you can follow this approach:
GRANT statements to assign roles or privileges.:::tip
While manually created users can still be integrated with a group provider and Ranger, this approach is more complex and less automated compared to using security integration. Therefore, it is not a recommended best practice.
:::
If you prefer to use StarRocks' built-in authorization system while still relying on external authentication, you can follow this approach: