mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-11 16:13:10 -06:00
Fix API wiring, linting
This commit is contained in:
parent
d67ffb2df4
commit
6850db6395
|
|
@ -18,7 +18,7 @@ import (
|
|||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
|
|
@ -168,7 +168,7 @@ func (p *oauth2IdentityProvider) getUserInfo(ctx context.Context, accessToken st
|
|||
}
|
||||
defer hresp.Body.Close() // nolint:errcheck
|
||||
|
||||
body, err := ioutil.ReadAll(hresp.Body)
|
||||
body, err := io.ReadAll(hresp.Body)
|
||||
if err != nil {
|
||||
return "", "", "", err
|
||||
}
|
||||
|
|
@ -205,7 +205,7 @@ func httpDo(ctx context.Context, hc *http.Client, req *http.Request) (*http.Resp
|
|||
contentType := resp.Header.Get("Content-Type")
|
||||
switch {
|
||||
case strings.HasPrefix(contentType, "text/plain"):
|
||||
bs, err := ioutil.ReadAll(resp.Body)
|
||||
bs, err := io.ReadAll(resp.Body)
|
||||
if err == nil {
|
||||
if len(bs) > 80 {
|
||||
bs = bs[:80]
|
||||
|
|
|
|||
|
|
@ -65,26 +65,26 @@ func main() {
|
|||
if *defaultsForCI {
|
||||
cfg.AppServiceAPI.DisableTLSValidation = true
|
||||
cfg.ClientAPI.RateLimiting.Enabled = false
|
||||
cfg.ClientAPI.Login.SSO.Enabled = true
|
||||
cfg.ClientAPI.Login.SSO.Providers = []config.IdentityProvider{
|
||||
{
|
||||
Brand: "github",
|
||||
OAuth2: config.OAuth2{
|
||||
ClientID: "aclientid",
|
||||
ClientSecret: "aclientsecret",
|
||||
},
|
||||
},
|
||||
{
|
||||
Brand: "google",
|
||||
OAuth2: config.OAuth2{
|
||||
ClientID: "aclientid",
|
||||
ClientSecret: "aclientsecret",
|
||||
},
|
||||
OIDC: config.OIDC{
|
||||
DiscoveryURL: "https://accounts.google.com/.well-known/openid-configuration",
|
||||
},
|
||||
},
|
||||
}
|
||||
cfg.ClientAPI.Login.SSO.Enabled = true
|
||||
cfg.ClientAPI.Login.SSO.Providers = []config.IdentityProvider{
|
||||
{
|
||||
Brand: "github",
|
||||
OAuth2: config.OAuth2{
|
||||
ClientID: "aclientid",
|
||||
ClientSecret: "aclientsecret",
|
||||
},
|
||||
},
|
||||
{
|
||||
Brand: "google",
|
||||
OAuth2: config.OAuth2{
|
||||
ClientID: "aclientid",
|
||||
ClientSecret: "aclientsecret",
|
||||
},
|
||||
OIDC: config.OIDC{
|
||||
DiscoveryURL: "https://accounts.google.com/.well-known/openid-configuration",
|
||||
},
|
||||
},
|
||||
}
|
||||
cfg.FederationAPI.DisableTLSValidation = false
|
||||
// don't hit matrix.org when running tests!!!
|
||||
cfg.FederationAPI.KeyPerspectives = config.KeyPerspectives{}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ import (
|
|||
|
||||
"github.com/matrix-org/dendrite/internal/httputil"
|
||||
"github.com/matrix-org/dendrite/userapi/api"
|
||||
"github.com/opentracing/opentracing-go"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
@ -28,26 +27,23 @@ const (
|
|||
QueryLocalpartForSSOPath = "/userapi/queryLocalpartForSSO"
|
||||
)
|
||||
|
||||
func (h *httpUserInternalAPI) QueryLocalpartForSSO(ctx context.Context, req *api.QueryLocalpartForSSORequest, res *api.QueryLocalpartForSSOResponse) error {
|
||||
span, ctx := opentracing.StartSpanFromContext(ctx, QueryLocalpartForSSOPath)
|
||||
defer span.Finish()
|
||||
|
||||
apiURL := h.apiURL + QueryLocalpartForSSOPath
|
||||
return httputil.PostJSON(ctx, span, h.httpClient, apiURL, req, res)
|
||||
func (h *httpUserInternalAPI) QueryLocalpartForSSO(ctx context.Context, request *api.QueryLocalpartForSSORequest, response *api.QueryLocalpartForSSOResponse) error {
|
||||
return httputil.CallInternalRPCAPI(
|
||||
"QuerytLocalpartForSSO", h.apiURL+QueryLocalpartForSSOPath,
|
||||
h.httpClient, ctx, request, response,
|
||||
)
|
||||
}
|
||||
|
||||
func (h *httpUserInternalAPI) PerformForgetSSO(ctx context.Context, req *api.PerformForgetSSORequest, res *struct{}) error {
|
||||
span, ctx := opentracing.StartSpanFromContext(ctx, PerformForgetSSOPath)
|
||||
defer span.Finish()
|
||||
|
||||
apiURL := h.apiURL + PerformForgetSSOPath
|
||||
return httputil.PostJSON(ctx, span, h.httpClient, apiURL, req, res)
|
||||
func (h *httpUserInternalAPI) PerformForgetSSO(ctx context.Context, request *api.PerformForgetSSORequest, response *struct{}) error {
|
||||
return httputil.CallInternalRPCAPI(
|
||||
"PerformForgetSSO", h.apiURL+PerformForgetSSOPath,
|
||||
h.httpClient, ctx, request, response,
|
||||
)
|
||||
}
|
||||
|
||||
func (h *httpUserInternalAPI) PerformSaveSSOAssociation(ctx context.Context, req *api.PerformSaveSSOAssociationRequest, res *struct{}) error {
|
||||
span, ctx := opentracing.StartSpanFromContext(ctx, PerformSaveSSOAssociationPath)
|
||||
defer span.Finish()
|
||||
|
||||
apiURL := h.apiURL + PerformSaveSSOAssociationPath
|
||||
return httputil.PostJSON(ctx, span, h.httpClient, apiURL, req, res)
|
||||
func (h *httpUserInternalAPI) PerformSaveSSOAssociation(ctx context.Context, request *api.PerformSaveSSOAssociationRequest, response *struct{}) error {
|
||||
return httputil.CallInternalRPCAPI(
|
||||
"PerformSaveSSOAssociation", h.apiURL+PerformSaveSSOAssociationPath,
|
||||
h.httpClient, ctx, request, response,
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue