Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: webauth no need to validate hostname on cli request #752

Merged
merged 2 commits into from
Feb 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading