Skip to content

Unable to retrieve SAML metadata when Accept header is set #12483

@khorshuheng

Description

@khorshuheng

Describe the bug
Currently, when a client retrieves SAML metadata via api/v3/providers/saml/1/metadata/?download , Authentik returns a response with Content Type set to application/xml as expected. However, if the same client send a request with the Accept header, such as:

curl -v "http://localhost:9000/api/v3/providers/saml/1/metadata/?download" -H "Accept: application/xml"

Authentik will return a 406 response instead. This is because, by default, DJango renderer only supports JSON:

REST_FRAMEWORK = {
    'DEFAULT_RENDERER_CLASSES': [
        'rest_framework.renderers.JSONRenderer',
        'rest_framework.renderers.BrowsableAPIRenderer',
    ]
}

https://pypi.org/project/djangorestframework-xml/ might be required in order to handle such case.

To Reproduce
Steps to reproduce the behavior:
curl -v "http://localhost:9000/api/v3/providers/saml/1/metadata/?download" -H "Accept: application/xml"
vs
curl -v "http://localhost:9000/api/v3/providers/saml/1/metadata/?download"

The former will fail with 406 whereas the latter will succeed.

Expected behavior
The endpoint to retrieve SAML metadata should return the content even if Accept header is set.

Screenshots
If applicable, add screenshots to help explain your problem.

Logs
Output of docker-compose logs or kubectl logs respectively

Version and Deployment (please complete the following information):

  • authentik version: 2024.12.0

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions