Repository navigation
Website content en overview reference pixiu other user httpfilter saml
关联资料(可能以 Java / Pixiu 为主)。原文按来源版本保留;使用前请读 版本与升级。 来源:原文 · 提交
84b35ebdab20· 返回目录
The dgp.filter.http.auth.saml filter allows Pixiu to act as a SAML Service Provider (SP).
With this filter enabled, Pixiu can:
- expose SP metadata for IdP registration
- redirect unauthenticated browser requests to the IdP login page
- receive the SAML response on the ACS endpoint
- create a session cookie after a successful login
- forward selected SAML assertion attributes to upstream services as HTTP headers
Typical IdPs include Keycloak, Okta, and Microsoft Entra ID.
- A browser requests a protected Pixiu route such as
/app. - Pixiu checks whether the request already carries a valid SAML session cookie.
- If no valid session exists, Pixiu redirects the browser to the IdP login page.
- After the user signs in, the IdP posts a
SAMLResponseto Pixiu's ACS endpoint. - Pixiu validates the assertion, creates a session cookie, and redirects the browser back to the original route.
- Later requests continue to the upstream service, with configured SAML attributes forwarded as headers.
http_filters:
- name: "dgp.filter.http.auth.saml"
config:
entity_id: "pixiu-saml-sp"
acs_url: "https://pixiu.example.com/saml/acs"
metadata_url: "https://pixiu.example.com/saml/metadata"
idp_metadata_url: "https://idp.example.com/app/metadata"
cert_file: "/etc/pixiu/saml/sp.crt"
key_file: "/etc/pixiu/saml/sp.key"
rules:
- match:
prefix: "/app"
forward_attributes:
- saml_attribute: "email"
header: "X-User-Email"
- saml_attribute: "displayName"
header: "X-User-Name"Instead of idp_metadata_url, you can load IdP metadata from a local file:
idp_metadata_file: "/etc/pixiu/saml/idp-metadata.xml"-
entity_id: SP entity ID advertised by Pixiu -
acs_url: Assertion Consumer Service endpoint that receives theSAMLResponse -
metadata_url: Pixiu SP metadata endpoint shared with the IdP administrator -
idp_metadata_url: URL used by Pixiu to fetch IdP metadata -
idp_metadata_file: local metadata file, used instead ofidp_metadata_url -
cert_file: SP certificate file -
key_file: SP private key file -
rules: protected path prefixes that require SAML login -
forward_attributes: mapping from SAML assertion attributes to upstream HTTP headers -
allow_idp_initiated: development-focused escape hatch for local HTTP testing when browsers drop the request-tracking cookie on the cross-site ACS POST -
err_msg: custom local reply message for SAML auth failures
-
acs_urlandmetadata_urlmust use the same scheme and host. -
metadata_urlis the SP metadata endpoint that the IdP imports. -
idp_metadata_urloridp_metadata_fileis used by Pixiu to learn the IdP signing key and SSO endpoint. - Pixiu removes client-supplied values for headers listed in
forward_attributesbefore writing SAML-derived values. - HTTPS is strongly recommended.
SAML SP-initiated login usually depends on a request-tracking cookie surviving the cross-site POST back from the IdP to the ACS endpoint.
- Under HTTPS, Pixiu uses
SameSite=None, which allows the cookie to be sent on the cross-site ACS POST. - Under plain HTTP development, browsers typically reject the combination needed for that flow, so Pixiu falls back to the browser default cookie policy.
- For local HTTP development, you may need
allow_idp_initiated: trueso the ACS flow can continue without relying on strictInResponseTovalidation.
In some local HTTP browser environments, the first login may not return cleanly to the original route because the request-tracking cookie is dropped on the ACS POST. In that case, the session may already have been created successfully. Revisit /app to verify the login result when testing the local sample.
A runnable sample is maintained in dubbo-go-pixiu-samples under auth/saml.