diff --git a/.gitignore b/.gitignore index 5ec6181..c5c484b 100644 --- a/.gitignore +++ b/.gitignore @@ -17,7 +17,6 @@ static/* !static/mediawiki.svg !static/openidconnect.svg !static/orcid.svg -!static/stackexchange.svg # Add .env file for Docker !docker/.env diff --git a/README.md b/README.md index b349d88..eb80dd6 100644 --- a/README.md +++ b/README.md @@ -269,7 +269,7 @@ Each object in the list of providers can have the following properties: - `credentialsNecessary` (optional) - Set to `true` if username and password credentials are necessary for this provider. Instead of a redirect (for OAuth), login-server will show a login form that will send the credentials to a POST endpoint. - `options` (mostly required) - A options object for the strategy, often containing client credentials for the authentication endpoint. - `image` (optional) - An image associated with the provider. Will be shown on the login page and in the list of connected identities. You can provide static images in the folder `static/`. The value for the property would then be `static/myimage.svg`. If the filename matches the `id` of the provider, the image will be automatically associated. -- `url` (optional) - A URL for the provider; will be linked on its image/icon under `/account`. There are default URLs for the strategies `github`, `orcid`, `mediawiki`, and `stackexchange`. +- `url` (optional) - A URL for the provider; will be linked on its image/icon under `/account`. There are default URLs for the strategies `github`, `orcid`, and `mediawiki`. The following is an example `providers.json` that shows how to configure each of the existing providers: @@ -305,17 +305,6 @@ The following is an example `providers.json` that shows how to configure each of "consumerSecret": "abcdef1234567890abcdef1234567890" } }, - { - "id": "stackexchange", - "strategy": "stackexchange", - "name": "Stack Exchange", - "template": "https://stackexchange.com/users/{id}", - "options": { - "clientID": "12345", - "clientSecret": "abcdef1234567890((", - "stackAppsKey": "1234567890abcdefg((" - } - }, { "id": "my-ldap", "strategy": "ldapauth", diff --git a/config.js b/config.js index 7f2d4e6..35b87a5 100644 --- a/config.js +++ b/config.js @@ -245,9 +245,6 @@ if (env != "test") { case "mediawiki": provider.url = "https://www.mediawiki.org/wiki/MediaWiki" break - case "stackexchange": - provider.url = "https://stackexchange.com" - break } } } diff --git a/static/stackexchange.svg b/static/stackexchange.svg deleted file mode 100644 index 321f653..0000000 --- a/static/stackexchange.svg +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/strategies/stackexchange.js b/strategies/stackexchange.js deleted file mode 100644 index c8c6b7a..0000000 --- a/strategies/stackexchange.js +++ /dev/null @@ -1,53 +0,0 @@ -/** - * OAuth2 Stategy adjusted for Stack Exchange. - */ - -import { Strategy } from "passport-oauth2" -import axios from "axios" -import config from "../config.js" - -export default (options, provider, callback) => { - const profileURL = "https://api.stackexchange.com/2.3/me" - options.authorizationURL = "https://stackexchange.com/oauth" - options.tokenURL = "https://stackexchange.com/oauth/access_token" - // Compatibility with old strategy that used passport-stack-exchange - if (options.stackAppsKey && !options.sessionKey) { - options.sessionKey = options.stackAppsKey - } - // Check if all required props are available - for (const prop of ["clientID", "clientSecret", "sessionKey"]) { - if (!options[prop]) { - const message = `Provider ${provider.id}: ${prop} is required. Will skip initialization.` - config.warn(message) - new Error(message) - } - } - return new Strategy(options, async (req, accessToken, refreshToken, profile, done) => { - // Load profile via API - const response = await axios.get(profileURL, { - params: { - key: options.sessionKey, - site: options.site || "stackoverflow", - access_token: accessToken, - }, - }) - profile = response?.data?.items?.[0] - if (!profile) { - // Fallback to /me/associated. - // This is necessary if the user has an account, but on a different Stack site than the one configured. - // Using the fallback, display_name cannot be obtained. - const response = await axios.get(profileURL + "/associated", { - params: { - key: options.sessionKey, - access_token: accessToken, - }, - }) - profile = response?.data?.items?.[0] - } - callback(req, accessToken, refreshToken, { - id: profile?.account_id, - name: profile?.display_name, - provider: provider.id, - }, done) - }) -}