mirror of
https://mau.dev/mautrix/go.git
synced 2026-03-14 14:25:53 +01:00
bridgev2/provisioning: allow custom user ID retrieval
Signed-off-by: Sumner Evans <sumner.evans@automattic.com>
This commit is contained in:
parent
4e8156519e
commit
a17dc5867e
1 changed files with 8 additions and 0 deletions
|
|
@ -54,6 +54,11 @@ type ProvisioningAPI struct {
|
|||
// GetAuthFromRequest is a custom function for getting the auth token from
|
||||
// the request if the Authorization header is not present.
|
||||
GetAuthFromRequest func(r *http.Request) string
|
||||
|
||||
// GetUserIDFromRequest is a custom function for getting the user ID to
|
||||
// authenticate as instead of using the user ID provided in the query
|
||||
// parameter.
|
||||
GetUserIDFromRequest func(r *http.Request) id.UserID
|
||||
}
|
||||
|
||||
type ProvLogin struct {
|
||||
|
|
@ -200,6 +205,9 @@ func (prov *ProvisioningAPI) AuthMiddleware(h http.Handler) http.Handler {
|
|||
return
|
||||
}
|
||||
userID := id.UserID(r.URL.Query().Get("user_id"))
|
||||
if userID == "" && prov.GetUserIDFromRequest != nil {
|
||||
userID = prov.GetUserIDFromRequest(r)
|
||||
}
|
||||
if auth != prov.br.Config.Provisioning.SharedSecret {
|
||||
var err error
|
||||
if strings.HasPrefix(auth, "openid:") {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue