@ovh-ux/manager-dev-server-config 4.0.0 → 5.0.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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,26 @@
1
+ ## [5.0.1](https://github.com/ovh/manager/compare/@ovh-ux/manager-dev-server-config@5.0.0...@ovh-ux/manager-dev-server-config@5.0.1) (2022-10-19)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **dev-server-config:** allow to define custom host ([b59706d](https://github.com/ovh/manager/commit/b59706d20a3cf221ada6ab7779d14268dac84e9b))
7
+
8
+
9
+
10
+ # [5.0.0](https://github.com/ovh/manager/compare/@ovh-ux/manager-dev-server-config@4.0.0...@ovh-ux/manager-dev-server-config@5.0.0) (2022-09-12)
11
+
12
+
13
+ ### Code Refactoring
14
+
15
+ * **dev-server-config:** remove registry proxy ([6339caf](https://github.com/ovh/manager/commit/6339caf22c59038a9fb45ae6c5fdfb336f6436e0))
16
+
17
+
18
+ ### BREAKING CHANGES
19
+
20
+ * **dev-server-config:** remove registry proxy configuration
21
+
22
+
23
+
1
24
  # [4.0.0](https://github.com/ovh/manager/compare/@ovh-ux/manager-dev-server-config@3.0.0...@ovh-ux/manager-dev-server-config@4.0.0) (2022-03-04)
2
25
 
3
26
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ovh-ux/manager-dev-server-config",
3
- "version": "4.0.0",
3
+ "version": "5.0.1",
4
4
  "description": "Provide OVHcloud Manager dev server config",
5
5
  "keywords": [
6
6
  "config",
@@ -1,11 +1,9 @@
1
1
  const aapi = require('./aapi');
2
2
  const dev = require('./dev');
3
3
  const v6 = require('./v6');
4
- const registry = require('./registry');
5
4
 
6
5
  module.exports = {
7
6
  aapi,
8
7
  dev,
9
8
  v6,
10
- registry,
11
9
  };
@@ -4,8 +4,8 @@ const TARGET = {
4
4
  us: 'https://us.ovhcloud.com',
5
5
  };
6
6
 
7
- module.exports = (region) => ({
8
- target: TARGET[region.toLowerCase()],
7
+ module.exports = (region, config = {}) => ({
8
+ target: config.host ? `https://${config.host}` : TARGET[region.toLowerCase()],
9
9
  context: ['/engine', '/auth'],
10
10
  changeOrigin: true,
11
11
  logLevel: 'silent',
package/src/sso/index.js CHANGED
@@ -3,31 +3,30 @@ const base64url = require('base64url');
3
3
  const cookie = require('cookie');
4
4
  const proxy = require('request');
5
5
 
6
- const CONFIG = {
6
+ const REGION_CONFIG = {
7
7
  ssoAuth: {
8
- eu: {
9
- host: 'www.ovh.com',
10
- baseUrl: 'https://www.ovh.com/cgi-bin/crosslogin.cgi',
11
- devLoginUrl: 'https://www.ovh.com/auth/requestDevLogin/',
12
- },
13
- ca: {
14
- host: 'ca.ovh.com',
15
- devLoginUrl: 'https://ca.ovh.com/auth/requestDevLogin/',
16
- baseUrl: 'https://ca.ovh.com/cgi-bin/crosslogin.cgi',
17
- },
18
- us: {
19
- host: 'us.ovhcloud.com',
20
- devLoginUrl: 'https://us.ovhcloud.com/auth/requestDevLogin/',
21
- baseUrl: 'https://us.ovhcloud.com/cgi-bin/crosslogin.cgi',
22
- },
8
+ eu: 'www.ovh.com',
9
+ ca: 'ca.ovh.com',
10
+ us: 'us.ovhcloud.com',
23
11
  },
24
12
  };
25
13
 
14
+ const buildConfig = (host) => ({
15
+ host,
16
+ devLoginUrl: `https://${host}/auth/requestDevLogin/`,
17
+ baseUrl: `https://${host}/cgi-bin/crosslogin.cgi`,
18
+ authURL: `https://${host}/auth`,
19
+ });
20
+
26
21
  module.exports = class Sso {
27
22
  config;
28
23
 
29
- constructor(region) {
30
- this.config = CONFIG.ssoAuth[region.toLowerCase()];
24
+ constructor(region, config = {}) {
25
+ if (config.host) {
26
+ this.config = buildConfig(config.host);
27
+ } else {
28
+ this.config = buildConfig(REGION_CONFIG.ssoAuth[region.toLowerCase()]);
29
+ }
31
30
  }
32
31
 
33
32
  login(req, res) {
@@ -114,6 +113,11 @@ module.exports = class Sso {
114
113
  );
115
114
  });
116
115
 
116
+ if (redirectionUrl.startsWith('/')) {
117
+ res.redirect(`${this.config.authURL}${redirectionUrl}`);
118
+ return;
119
+ }
120
+
117
121
  res.redirect(redirectionUrl);
118
122
  }
119
123
 
@@ -1,16 +0,0 @@
1
- const TARGET = {
2
- eu: 'https://www.ovh.com/manager/fragments',
3
- ca: 'https://ca.ovh.com/manager/fragments',
4
- us: 'https://us.ovhcloud.com/manager/fragments',
5
- local: 'http://localhost:8888',
6
- };
7
-
8
- module.exports = (region, { local = false, registryUrl }) => ({
9
- target: registryUrl || TARGET[local ? 'local' : region.toLowerCase()],
10
- context: '/manager/fragments',
11
- pathRewrite: {
12
- '^/manager/fragments/': '/',
13
- },
14
- changeOrigin: true,
15
- logLevel: 'silent',
16
- });