Reference#
This reference describes the public scim2-flask API. The scim2-server reference describes the storage contract, the service and the other classes the extension relies on.
Extension#
The Flask extension serving the SCIM endpoints.
- class scim2_flask.ScimServer(storage: ScimStorage, provider: ScimProvider, app: Flask | None = None, *, service: ScimService | None = None, url_prefix: str = '/scim/v2', name: str = 'scim')[source]#
Flask extension exposing a SCIM 2.0 server backed by a
ScimStorage.The
ScimProviderdescribes the service: the resource types it serves, the configuration it announces, and the policy the extension applies when it reads and writes payloads.Usage:
storage = MyStorage() scim_server = ScimServer(storage, ScimProvider(models=[User])) scim_server.init_app(app)
Or with the application factory pattern:
scim_server = ScimServer(storage, ScimProvider(models=[User])) def create_app(): app = Flask(__name__) scim_server.init_app(app) return app
- Parameters:
storage¶ – The storage that holds the resources.
provider¶ – The service description. It must declare at least one resource type.
app¶ – The application to register on right away, if any.
service¶ – The service serving the requests. By default,
init_app()builds one uponprovider, with thesecret_keyof the application as the secret of the cursors. Pass a subclass ofScimServiceto change one of its steps, such as the URL of the resources.url_prefix¶ – The URL prefix of the SCIM endpoints.
name¶ – The name of the blueprint, and so the prefix of its endpoints. Give each instance its own name to serve several SCIM servers from one application.
- create_blueprint() Blueprint[source]#
Return the
Blueprintserving the SCIM endpoints.It has one endpoint per route of
ROUTES, named after the route, such asscim.query, whose arguments areresource_endpointandresource_id. Afallbackendpoint answers the other requests with a SCIM error.
- get_subject() Any[source]#
Return the authenticated subject of the current request.
It returns
Noneby default. Override it to pass the subject your application authenticated to the service, forauthorize()and/Me.
- init_app(app: Flask) None[source]#
Register the SCIM blueprint on
app, underurl_prefix.The extension is then available in the
"scim"entry ofextensions, under itsname. Load the configuration of the application first: the default service reads itsSECRET_KEYhere.- Raises:
ValueError – When the configuration of the service announces cursor pagination, and the application has no
SECRET_KEY.
- read_body(scim_request: ScimRequest) bytes[source]#
Read the body of the current request, up to one byte more than the service accepts.
The service answers a larger body with a 413. The
MAX_CONTENT_LENGTHof the application still applies.
- read_request() ScimRequest[source]#
Return the
ScimRequestof the current Flask request.