Matrix doesn't actually define how one should do authentication though... every homeserver software is free to implement it however they want.
Auth for clients is also specified in the spec - there is some scope for homeservers to freestyle, but nowadays they have to implement OIDC: https://spec.matrix.org/latest/client-server-api/#client-aut...