@cerema/cadriciel 1.4.15 → 1.4.17
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/cli/global/login.js +10 -9
- package/lib/cadriciel.js +0 -7
- package/package.json +1 -1
package/cli/global/login.js
CHANGED
|
@@ -14,12 +14,16 @@ module.exports = (args) => {
|
|
|
14
14
|
const querystring = require('querystring');
|
|
15
15
|
|
|
16
16
|
const app = express();
|
|
17
|
-
const PORT = 4200;
|
|
18
|
-
|
|
19
|
-
const KEYCLOAK_SERVER = 'https://orion-recette.cerema.fr';
|
|
20
17
|
const REALM = 'CeremaApps';
|
|
21
|
-
|
|
22
|
-
const
|
|
18
|
+
|
|
19
|
+
const KEYCLOAK_SERVER = 'https://orion.cerema.fr';
|
|
20
|
+
const PORT = 14211;
|
|
21
|
+
const CLIENT_ID = 'cadriciel_login';
|
|
22
|
+
|
|
23
|
+
//const KEYCLOAK_SERVER = 'https://orion-recette.cerema.fr';
|
|
24
|
+
//const PORT = 4200;
|
|
25
|
+
//const CLIENT_ID = 'marep_dev';
|
|
26
|
+
const REDIRECT_URI = 'http://localhost:' + PORT + '/login';
|
|
23
27
|
|
|
24
28
|
const INDEX_HTML = fs.readFileSync(
|
|
25
29
|
__dirname + '/../assets/index.html',
|
|
@@ -61,7 +65,7 @@ module.exports = (args) => {
|
|
|
61
65
|
|
|
62
66
|
const auth = async (wellKnownConfig) => {
|
|
63
67
|
app.use(express.static(__dirname + '/../assets'));
|
|
64
|
-
app.get('/
|
|
68
|
+
app.get('/login', (req, res) => {
|
|
65
69
|
const code = req.query.code;
|
|
66
70
|
axios
|
|
67
71
|
.post(
|
|
@@ -92,7 +96,6 @@ module.exports = (args) => {
|
|
|
92
96
|
try {
|
|
93
97
|
var response = await cadriciel.get('/login');
|
|
94
98
|
} catch (e) {
|
|
95
|
-
console.log(e);
|
|
96
99
|
console.log(' ');
|
|
97
100
|
console.log(
|
|
98
101
|
chalk.red(' [AUTH]') +
|
|
@@ -110,7 +113,6 @@ module.exports = (args) => {
|
|
|
110
113
|
response.token,
|
|
111
114
|
async (err) => {
|
|
112
115
|
if (err) {
|
|
113
|
-
console.log(err);
|
|
114
116
|
return res
|
|
115
117
|
.status(500)
|
|
116
118
|
.send("Erreur lors de l'écriture du token.");
|
|
@@ -132,7 +134,6 @@ module.exports = (args) => {
|
|
|
132
134
|
);
|
|
133
135
|
})
|
|
134
136
|
.catch((error) => {
|
|
135
|
-
console.log(error);
|
|
136
137
|
res
|
|
137
138
|
.status(500)
|
|
138
139
|
.send("Erreur lors de l'échange du code d'autorisaton.");
|
package/lib/cadriciel.js
CHANGED
|
@@ -13,7 +13,6 @@ class CadricielAPI {
|
|
|
13
13
|
token = fs.readFileSync(HomeDir + '/account', 'utf-8');
|
|
14
14
|
token = token.replace(/\n/g, '');
|
|
15
15
|
} catch (e) {
|
|
16
|
-
console.log(e);
|
|
17
16
|
console.log(
|
|
18
17
|
chalk.bold(' [AUTH] ') +
|
|
19
18
|
chalk.red(
|
|
@@ -29,17 +28,11 @@ class CadricielAPI {
|
|
|
29
28
|
timeout: 10000,
|
|
30
29
|
headers: { Authorization: 'Bearer ' + token },
|
|
31
30
|
});
|
|
32
|
-
console.log({
|
|
33
|
-
baseURL: baseURL,
|
|
34
|
-
timeout: 10000,
|
|
35
|
-
headers: { Authorization: 'Bearer ' + token },
|
|
36
|
-
});
|
|
37
31
|
}
|
|
38
32
|
|
|
39
33
|
async get(url, params = {}) {
|
|
40
34
|
try {
|
|
41
35
|
const response = await this.client.get(url, { params });
|
|
42
|
-
console.log(response);
|
|
43
36
|
return response.data;
|
|
44
37
|
} catch (error) {
|
|
45
38
|
throw error;
|