Registration¶
RFC 7591 Dynamic Client Registration. build_register_handler assembles a
Starlette endpoint that parses a registration request, applies host-supplied
policy, and delegates persistence to a pluggable ClientRegistry.
RFC 7591 Dynamic Client Registration components.
build_register_handler¶
build_register_handler
¶
build_register_handler(
registry: ClientRegistry,
*,
default_scope: str,
rate_limiter: SlidingWindowRateLimiter | None = None,
auth_validator: RegistrationAuthValidator | None = None,
get_client_ip: ClientIpResolver | None = None,
default_redirect_uris: Sequence[str] = (),
redirect_uri_rewriters: Iterable[
RedirectUriRewriter
] = (),
redirect_uri_validator: RedirectUriValidator
| None = _default_redirect_uri_valid,
client_name_factory: ClientNameFactory | None = None,
post_register_hooks: Iterable[PostRegisterHook] = (),
) -> Callable[[Request], Awaitable[Response]]
Return a Starlette handler implementing RFC 7591 registration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
registry
|
ClientRegistry
|
Persistence backend that issues and stores clients. |
required |
default_scope
|
str
|
Scope granted when the request omits one. Also included in the registration response. |
required |
rate_limiter
|
SlidingWindowRateLimiter | None
|
Optional per-IP limiter applied before parsing.
Skipped when |
None
|
auth_validator
|
RegistrationAuthValidator | None
|
Optional async callable gating the endpoint
(RFC 7591 §3.1 initial access token). Invoked before the
rate-limit check; a falsy return yields |
None
|
get_client_ip
|
ClientIpResolver | None
|
Resolves the rate-limit key from the request.
Defaults to the direct TCP peer ( |
None
|
default_redirect_uris
|
Sequence[str]
|
Fallback |
()
|
redirect_uri_rewriters
|
Iterable[RedirectUriRewriter]
|
Ordered list of callables applied to the
|
()
|
redirect_uri_validator
|
RedirectUriValidator | None
|
Predicate applied to each redirect_uri
after rewriting; any URI returning falsy is rejected with
|
_default_redirect_uri_valid
|
client_name_factory
|
ClientNameFactory | None
|
Override the client name. Receives the
parsed request; returns the name to assign. When |
None
|
post_register_hooks
|
Iterable[PostRegisterHook]
|
Async callables invoked with the newly
issued |
()
|
Source code in mcp_authflow/registration/handler.py
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 | |
ClientRegistry¶
ClientRegistry
¶
Bases: ABC
Persistence interface for dynamically registered OAuth clients.
Implementations decide where clients live (in-memory, database,
delegated to an upstream identity service). The handler factory in
:mod:mcp_authflow.registration.handler is storage-agnostic and
drives this interface.
ClientRegistrationRequest¶
ClientRegistrationRequest
dataclass
¶
ClientRegistrationRequest(
client_name: str | None,
redirect_uris: list[str],
grant_types: list[str],
response_types: list[str],
token_endpoint_auth_method: str,
scope: str | None,
extra: dict[str, object] = dict(),
)
Parsed and normalized RFC 7591 registration request.
Only the fields used by the handler are modeled; additional metadata
received in the request body is preserved in extra for adapters
that want to forward it to a backend.
is_public_client
property
¶
True if the requested auth method indicates a public client.
RegisteredClient¶
RegisteredClient
dataclass
¶
RegisteredClient(
client_id: str,
client_secret: str | None,
client_name: str | None,
redirect_uris: list[str],
grant_types: list[str],
response_types: list[str],
token_endpoint_auth_method: str,
scope: str | None,
client_id_issued_at: int,
client_secret_expires_at: int = 0,
)
An OAuth client that has been issued credentials.
Returned by ClientRegistry.create_client. client_secret is
None for public clients (token_endpoint_auth_method == "none").
MemoryClientRegistry¶
MemoryClientRegistry
¶
Bases: ClientRegistry
Process-local client registry. Not persistent across restarts.