mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-05 21:23:10 -06:00
golangci-lint fixes.
This commit is contained in:
parent
6de730b2ee
commit
46b4abd4cf
|
|
@ -39,7 +39,6 @@ type oauth2IdentityProvider struct {
|
|||
|
||||
scopes []string
|
||||
responseMimeType string
|
||||
issPath string
|
||||
subPath string
|
||||
emailPath string
|
||||
displayNamePath string
|
||||
|
|
@ -79,7 +78,7 @@ func (p *oauth2IdentityProvider) ProcessCallback(ctx context.Context, callbackUR
|
|||
desc = error
|
||||
}
|
||||
switch error {
|
||||
case "unauthorized_client", "access_denied":
|
||||
case "unauthorized_client", "access_denied": // nolint:misspell
|
||||
return nil, jsonerror.Forbidden("SSO said no: " + desc)
|
||||
default:
|
||||
return nil, fmt.Errorf("SSO failed: %v", error)
|
||||
|
|
@ -135,7 +134,7 @@ func (p *oauth2IdentityProvider) getAccessToken(ctx context.Context, callbackURL
|
|||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
defer hresp.Body.Close()
|
||||
defer hresp.Body.Close() // nolint:errcheck
|
||||
|
||||
var resp oauth2TokenResponse
|
||||
if err := json.NewDecoder(hresp.Body).Decode(&resp); err != nil {
|
||||
|
|
@ -178,7 +177,7 @@ func (p *oauth2IdentityProvider) getUserInfo(ctx context.Context, accessToken st
|
|||
if err != nil {
|
||||
return "", "", "", err
|
||||
}
|
||||
defer hresp.Body.Close()
|
||||
defer hresp.Body.Close() // nolint:errcheck
|
||||
|
||||
body, err := ioutil.ReadAll(hresp.Body)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@ func oidcDiscover(ctx context.Context, url string) (*oidcDiscovery, error) {
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer hresp.Body.Close()
|
||||
defer hresp.Body.Close() // nolint:errcheck
|
||||
|
||||
var disc oidcDiscovery
|
||||
if err := json.NewDecoder(hresp.Body).Decode(&disc); err != nil {
|
||||
|
|
|
|||
|
|
@ -193,7 +193,7 @@ func SSOCallback(
|
|||
return util.RedirectResponse(result.RedirectURL)
|
||||
}
|
||||
|
||||
localpart, err := verifySSOUserIdentifier(ctx, userAPI, result.Identifier, serverName)
|
||||
localpart, err := verifySSOUserIdentifier(ctx, userAPI, result.Identifier)
|
||||
if err != nil {
|
||||
util.GetLogger(ctx).WithError(err).WithField("ssoIdentifier", result.Identifier).Error("failed to find user")
|
||||
return util.JSONResponse{
|
||||
|
|
@ -278,7 +278,7 @@ func parseNonce(s string) (redirectURL *url.URL, _ error) {
|
|||
// verifySSOUserIdentifier resolves an sso.UserIdentifier to a local
|
||||
// part using the User API. Returns empty if there is no associated
|
||||
// user.
|
||||
func verifySSOUserIdentifier(ctx context.Context, userAPI userAPIForSSO, id *sso.UserIdentifier, serverName gomatrixserverlib.ServerName) (localpart string, _ error) {
|
||||
func verifySSOUserIdentifier(ctx context.Context, userAPI userAPIForSSO, id *sso.UserIdentifier) (localpart string, _ error) {
|
||||
req := &uapi.QueryLocalpartForSSORequest{
|
||||
Namespace: id.Namespace,
|
||||
Issuer: id.Issuer,
|
||||
|
|
|
|||
|
|
@ -190,11 +190,11 @@ type IdentityProvider struct {
|
|||
func (idp *IdentityProvider) Verify(configErrs *ConfigErrors) {
|
||||
checkNotEmpty(configErrs, "client_api.sso.providers.id", idp.ID)
|
||||
if !checkIdentityProviderBrand(SSOBrand(idp.ID)) {
|
||||
configErrs.Add(fmt.Sprintf("unrecognized ID config key %q: %s", "client_api.sso.providers", idp.ID))
|
||||
configErrs.Add(fmt.Sprintf("unrecognised ID config key %q: %s", "client_api.sso.providers", idp.ID))
|
||||
}
|
||||
checkNotEmpty(configErrs, "client_api.sso.providers.name", idp.Name)
|
||||
if idp.Brand != "" && !checkIdentityProviderBrand(idp.Brand) {
|
||||
configErrs.Add(fmt.Sprintf("unrecognized brand in identity provider %q for config key %q: %s", idp.ID, "client_api.sso.providers", idp.Brand))
|
||||
configErrs.Add(fmt.Sprintf("unrecognised brand in identity provider %q for config key %q: %s", idp.ID, "client_api.sso.providers", idp.Brand))
|
||||
}
|
||||
if idp.Icon != "" {
|
||||
checkURL(configErrs, "client_api.sso.providers.icon", idp.Icon)
|
||||
|
|
@ -215,7 +215,7 @@ func (idp *IdentityProvider) Verify(configErrs *ConfigErrors) {
|
|||
checkNotEmpty(configErrs, "client_api.sso.providers.oidc.client_secret", idp.OIDC.ClientSecret)
|
||||
|
||||
default:
|
||||
configErrs.Add(fmt.Sprintf("unrecognized type in identity provider %q for config key %q: %s", idp.ID, "client_api.sso.providers", typ))
|
||||
configErrs.Add(fmt.Sprintf("unrecognised type in identity provider %q for config key %q: %s", idp.ID, "client_api.sso.providers", typ))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue