Skip to content

Commit

Permalink
fix: webauth no need to validate hostname on cli request (#752)
Browse files Browse the repository at this point in the history
  • Loading branch information
fengmk2 authored Feb 8, 2025
1 parent c23a669 commit f1fc249
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 2 additions & 2 deletions app/port/webauth/WebauthController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ import { genRSAKeys, decryptRSA } from '../../common/CryptoUtil';
import { getBrowserTypeForWebauthn } from '../../common/UserUtil';

const LoginRequestRule = Type.Object({
// cli 所在机器的 hostname
hostname: Type.String({ minLength: 1, maxLength: 100 }),
// cli 所在机器的 hostname,最新版本 npm cli 已经不会上报 hostname
hostname: Type.Optional(Type.String({ minLength: 1, maxLength: 100 })),
});
type LoginRequest = Static<typeof LoginRequestRule>;

Expand Down
5 changes: 2 additions & 3 deletions test/port/webauth/webauthController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,11 @@ describe('test/port/webauth/webauthController.test.ts', () => {
assert.equal(loginSessionId.length, 36);
});

it('should check hostname', async () => {
it('should hostname is optional', async () => {
const res = await app.httpRequest()
.post('/-/v1/login');

assert.equal(res.status, 422);
assert.equal(res.body.error, "[INVALID_PARAM] must have required property 'hostname'");
assert.equal(res.status, 200);
});
});

Expand Down

0 comments on commit f1fc249

Please sign in to comment.