oidc-login 1.1.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.mjs +9 -5
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -182,14 +182,18 @@ async function discover({ issuer, clientId, clientSecret, clientAuthentication,
182
182
  ...fetch ? { [client.customFetch]: fetch } : {},
183
183
  ...insecure ? { execute: [client.allowInsecureRequests] } : {}
184
184
  });
185
- const { authorization_endpoint, token_endpoint } = config.serverMetadata();
186
- if (![authorization_endpoint, token_endpoint].every((endpoint) => isEndpointUrl(endpoint, insecure))) throw new Error("The issuer metadata has no valid authorization or token endpoint.");
185
+ const { authorization_endpoint, token_endpoint, userinfo_endpoint, jwks_uri } = config.serverMetadata();
186
+ if (![authorization_endpoint, token_endpoint].every((endpoint) => isEndpointUrl(endpoint, insecure)) || ![userinfo_endpoint, jwks_uri].every((endpoint) => endpoint === void 0 || isEndpointUrl(endpoint, insecure))) throw new Error("The issuer metadata has an invalid endpoint.");
187
187
  return config;
188
188
  }
189
- /** Checks that an endpoint from the issuer metadata is an absolute URL with an allowed protocol. */
189
+ /**
190
+ * Checks that an endpoint from the issuer metadata is an absolute URL with an allowed protocol.
191
+ *
192
+ * A plain HTTP issuer on a loopback host may name HTTPS endpoints or plain HTTP endpoints on loopback hosts, so that the client secret and tokens do not leave the machine unencrypted.
193
+ */
190
194
  function isEndpointUrl(value, insecure) {
191
195
  if (typeof value !== "string" || !URL.canParse(value)) return false;
192
- const { protocol } = new URL(value);
193
- return protocol === "https:" || insecure && protocol === "http:";
196
+ const { protocol, hostname } = new URL(value);
197
+ return protocol === "https:" || insecure && protocol === "http:" && isLoopbackHostname(hostname);
194
198
  }
195
199
  export { OidcLoginError, createOidcLogin, isSecureIssuerUrl };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oidc-login",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "OpenID Connect login flow for web apps on top of openid-client",
5
5
  "homepage": "https://github.com/IlyaSemenov/oidc-login#readme",
6
6
  "bugs": "https://github.com/IlyaSemenov/oidc-login/issues",