Skip to content

Commit 0752751

Browse files
committed
deploy: ade91ca
1 parent 1588f21 commit 0752751

File tree

17 files changed

+154
-147
lines changed

17 files changed

+154
-147
lines changed

controllers/AuthController.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ <h3 id="methods">
573573
import { ReqIdentity } from &#x27;~/_common/decorators/params/req-identity.decorator&#x27;;
574574
import { AgentType } from &#x27;~/_common/types/agent.type&#x27;;
575575
import { hash } from &#x27;crypto&#x27;;
576-
import { omit } from &#x27;radash&#x27;;
576+
import { omit, pick } from &#x27;radash&#x27;;
577577

578578
@Public()
579579
@ApiTags(&#x27;core/auth&#x27;)
@@ -601,12 +601,12 @@ <h3 id="methods">
601601
@UseGuards(AuthGuard(&#x27;jwt&#x27;))
602602
@ApiOperation({ summary: &#x27;Récupération de la session en cours&#x27; })
603603
public async session(@Res() res: Response, @ReqIdentity() identity: AgentType): Promise&lt;Response&gt; {
604-
this.logger.debug(&#x60;Session request for ${identity.id} (${identity.email})&#x60;);
604+
this.logger.debug(&#x60;Session request for ${identity._id} (${identity.email})&#x60;);
605605
const user &#x3D; await this.service.getSessionData(identity);
606-
this.logger.debug(&#x60;Session data delivered for ${identity.id} (${identity.email}) with ${JSON.stringify(user)}&#x60;);
606+
this.logger.debug(&#x60;Session data delivered for ${identity._id} (${identity.email}) with ${JSON.stringify(user)}&#x60;);
607607
return res.status(HttpStatus.OK).json({
608608
user: {
609-
...omit(user, [&#x27;security&#x27;]),
609+
...omit(user, [&#x27;security&#x27;, &#x27;metadata&#x27;]),
610610
sseToken: hash(&#x27;sha256&#x27;, user.security.secretKey),
611611
},
612612
});

injectables/AuthService.html

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -454,8 +454,8 @@ <h3 id="methods">
454454

455455
<tr>
456456
<td class="col-md-4">
457-
<div class="io-line">Defined in <a href="" data-line="193"
458-
class="link-to-prism">src/core/auth/auth.service.ts:193</a></div>
457+
<div class="io-line">Defined in <a href="" data-line="195"
458+
class="link-to-prism">src/core/auth/auth.service.ts:195</a></div>
459459
</td>
460460
</tr>
461461

@@ -524,8 +524,8 @@ <h3 id="methods">
524524

525525
<tr>
526526
<td class="col-md-4">
527-
<div class="io-line">Defined in <a href="" data-line="116"
528-
class="link-to-prism">src/core/auth/auth.service.ts:116</a></div>
527+
<div class="io-line">Defined in <a href="" data-line="118"
528+
class="link-to-prism">src/core/auth/auth.service.ts:118</a></div>
529529
</td>
530530
</tr>
531531

@@ -618,8 +618,8 @@ <h3 id="methods">
618618

619619
<tr>
620620
<td class="col-md-4">
621-
<div class="io-line">Defined in <a href="" data-line="166"
622-
class="link-to-prism">src/core/auth/auth.service.ts:166</a></div>
621+
<div class="io-line">Defined in <a href="" data-line="168"
622+
class="link-to-prism">src/core/auth/auth.service.ts:168</a></div>
623623
</td>
624624
</tr>
625625

@@ -728,8 +728,8 @@ <h3 id="methods">
728728

729729
<tr>
730730
<td class="col-md-4">
731-
<div class="io-line">Defined in <a href="" data-line="181"
732-
class="link-to-prism">src/core/auth/auth.service.ts:181</a></div>
731+
<div class="io-line">Defined in <a href="" data-line="183"
732+
class="link-to-prism">src/core/auth/auth.service.ts:183</a></div>
733733
</td>
734734
</tr>
735735

@@ -1180,7 +1180,7 @@ <h3 id="inputs">
11801180
import { Agents } from &#x27;~/core/agents/_schemas/agents.schema&#x27;;
11811181
import { AgentsService } from &#x27;~/core/agents/agents.service&#x27;;
11821182
import { AgentType } from &#x27;~/_common/types/agent.type&#x27;;
1183-
import { omit } from &#x27;radash&#x27;;
1183+
import { omit, pascal, pick } from &#x27;radash&#x27;;
11841184
import { JwtPayload } from &#x27;jsonwebtoken&#x27;;
11851185
import { JwtService } from &#x27;@nestjs/jwt&#x27;;
11861186
import { resolve } from &#x27;path&#x27;;
@@ -1253,6 +1253,7 @@ <h3 id="inputs">
12531253

12541254
// eslint-disable-next-line
12551255
public async verifyIdentity(payload: any &amp; { identity: AgentType &amp; { token: string } }): Promise&lt;any&gt; {
1256+
console.log(&#x27;payload&#x27;, payload);
12561257
if (payload.scopes.includes(&#x27;offline&#x27;)) {
12571258
return payload.identity;
12581259
}
@@ -1272,6 +1273,7 @@ <h3 id="inputs">
12721273
const identity &#x3D; await this.redis.get([this.ACCESS_TOKEN_PREFIX, payload.jti].join(&#x27;:&#x27;));
12731274
if (identity) {
12741275
const data &#x3D; JSON.parse(identity);
1276+
console.log(&#x27;data&#x27;, data);
12751277
const success &#x3D; await this.agentsService.model.countDocuments({
12761278
_id: payload.identity._id,
12771279
&#x27;security.secretKey&#x27;: data.identity?.security?.secretKey,
@@ -1297,7 +1299,7 @@ <h3 id="inputs">
12971299
if (options?.scopes) scopes.push(...options.scopes);
12981300
const jwtid &#x3D; &#x60;${identity._id}_${randomBytes(16).toString(&#x27;hex&#x27;)}&#x60;;
12991301
const access_token &#x3D; this.jwtService.sign(
1300-
{ identity, scopes },
1302+
{ identity: pick(identity, [&#x27;_id&#x27;, &#x27;username&#x27;, &#x27;email&#x27;]), scopes },
13011303
{
13021304
expiresIn: this.ACCESS_TOKEN_EXPIRES_IN,
13031305
jwtid,
@@ -1319,10 +1321,11 @@ <h3 id="inputs">
13191321
[this.REFRESH_TOKEN_PREFIX, refresh_token].join(this.TOKEN_PATH_SEPARATOR),
13201322
this.REFRESH_TOKEN_EXPIRES_IN,
13211323
);
1324+
const userIdentity &#x3D; await this.agentsService.findOne&lt;Agents&gt;({ _id: identity._id });
13221325
await this.redis.set(
13231326
[this.ACCESS_TOKEN_PREFIX, jwtid].join(this.TOKEN_PATH_SEPARATOR),
13241327
JSON.stringify({
1325-
identity,
1328+
identity: userIdentity.toJSON(),
13261329
refresh_token,
13271330
}),
13281331
&#x27;EX&#x27;,
@@ -1334,19 +1337,18 @@ <h3 id="inputs">
13341337
};
13351338
}
13361339

1337-
//TODO: change any
13381340
public async getSessionData(identity: AgentType): Promise&lt;AgentType&gt; {
1339-
// const entity &#x3D; await this.agentsService.findOne&lt;Agents&gt;(
1340-
// { _id: identity.entityId },
1341-
// {
1342-
// projection: {
1343-
// metadata: 0,
1344-
// },
1345-
// },
1346-
// )
1341+
const entity &#x3D; await this.agentsService.findOne&lt;Agents&gt;(
1342+
{ _id: identity._id },
1343+
{
1344+
projection: {
1345+
metadata: 0,
1346+
password: 0,
1347+
},
1348+
},
1349+
)
13471350
return {
1348-
...identity,
1349-
// entity,
1351+
...omit(entity.toJSON(), [&#x27;password&#x27;]),
13501352
};
13511353
}
13521354

injectables/JwtStrategy.html

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,11 @@ <h3 id="inputs">
355355
<i>Type : </i> <code><a href="../classes/Logger.html" target="_self" >Logger</a></code>
356356

357357
</td>
358+
</tr>
359+
<tr>
360+
<td class="col-md-4">
361+
<i>Default value : </i><code>new Logger(JwtStrategy.name)</code>
362+
</td>
358363
</tr>
359364
<tr>
360365
<td class="col-md-4">
@@ -382,7 +387,7 @@ <h3 id="inputs">
382387

383388
@Injectable()
384389
export class JwtStrategy extends PassportStrategy(Strategy, &#x27;jwt&#x27;) {
385-
protected logger: Logger;
390+
protected logger: Logger &#x3D; new Logger(JwtStrategy.name);
386391

387392
constructor(
388393
private readonly auth: AuthService,
@@ -402,7 +407,7 @@ <h3 id="inputs">
402407
payload: JwtPayload &amp; { identity: AgentType },
403408
done: VerifiedCallback,
404409
): Promise&lt;void&gt; {
405-
this.logger.verbose(&#x60;Atempt to authenticate with JTI: &lt;${payload.jti}&gt;&#x60;, JwtStrategy.name);
410+
this.logger.verbose(&#x60;Atempt to authenticate with JTI: &lt;${payload.jti}&gt;&#x60;);
406411
if (!payload?.identity) return done(new UnauthorizedException(), false);
407412
const user &#x3D; await this.auth.verifyIdentity(payload);
408413

js/search/search_index.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

modules/IdentitiesJsonformsModule.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,14 @@
117117
<title>cluster_IdentitiesJsonformsModule</title>
118118
<polygon fill="none" stroke="black" stroke-dasharray="1,5" points="116,-70 116,-268 380,-268 380,-70 116,-70"/>
119119
</g>
120-
<g id="clust4" class="cluster">
121-
<title>cluster_IdentitiesJsonformsModule_exports</title>
122-
<polygon fill="none" stroke="black" points="154,-208 154,-260 342,-260 342,-208 154,-208"/>
123-
</g>
124120
<g id="clust6" class="cluster">
125121
<title>cluster_IdentitiesJsonformsModule_providers</title>
126122
<polygon fill="none" stroke="black" points="124,-78 124,-130 372,-130 372,-78 124,-78"/>
127123
</g>
124+
<g id="clust4" class="cluster">
125+
<title>cluster_IdentitiesJsonformsModule_exports</title>
126+
<polygon fill="none" stroke="black" points="154,-208 154,-260 342,-260 342,-208 154,-208"/>
127+
</g>
128128
<!-- IdentitiesJsonformsService -->
129129
<g id="node1" class="node">
130130
<title>IdentitiesJsonformsService </title>

modules/IdentitiesJsonformsModule/dependencies.svg

Lines changed: 4 additions & 4 deletions
Loading

modules/IdentitiesModule.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,14 +121,14 @@
121121
<title>cluster_IdentitiesModule_imports</title>
122122
<polygon fill="none" stroke="black" points="523,-78 523,-130 661,-130 661,-78 523,-78"/>
123123
</g>
124-
<g id="clust6" class="cluster">
125-
<title>cluster_IdentitiesModule_providers</title>
126-
<polygon fill="none" stroke="black" points="16,-78 16,-130 515,-130 515,-78 16,-78"/>
127-
</g>
128124
<g id="clust4" class="cluster">
129125
<title>cluster_IdentitiesModule_exports</title>
130126
<polygon fill="none" stroke="black" points="312,-208 312,-260 470,-260 470,-208 312,-208"/>
131127
</g>
128+
<g id="clust6" class="cluster">
129+
<title>cluster_IdentitiesModule_providers</title>
130+
<polygon fill="none" stroke="black" points="16,-78 16,-130 515,-130 515,-78 16,-78"/>
131+
</g>
132132
<!-- FilestorageModule -->
133133
<g id="node1" class="node">
134134
<title>FilestorageModule</title>

modules/IdentitiesModule/dependencies.svg

Lines changed: 4 additions & 4 deletions
Loading

modules/JobsModule.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,14 @@
117117
<title>cluster_JobsModule</title>
118118
<polygon fill="none" stroke="black" stroke-dasharray="1,5" points="175,-70 175,-268 321,-268 321,-70 175,-70"/>
119119
</g>
120-
<g id="clust6" class="cluster">
121-
<title>cluster_JobsModule_providers</title>
122-
<polygon fill="none" stroke="black" points="183,-78 183,-130 313,-130 313,-78 183,-78"/>
123-
</g>
124120
<g id="clust4" class="cluster">
125121
<title>cluster_JobsModule_exports</title>
126122
<polygon fill="none" stroke="black" points="197,-208 197,-260 299,-260 299,-208 197,-208"/>
127123
</g>
124+
<g id="clust6" class="cluster">
125+
<title>cluster_JobsModule_providers</title>
126+
<polygon fill="none" stroke="black" points="183,-78 183,-130 313,-130 313,-78 183,-78"/>
127+
</g>
128128
<!-- JobsService -->
129129
<g id="node1" class="node">
130130
<title>JobsService </title>

modules/JobsModule/dependencies.svg

Lines changed: 4 additions & 4 deletions
Loading

0 commit comments

Comments
 (0)