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(v3proxy): allow cookie auth on v3/send #1020

Merged
merged 1 commit into from
Jan 9, 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 servers/v3-proxy-api/src/graph/graphQLClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import * as Sentry from '@sentry/node';
import { serverLogger } from '@pocket-tools/ts-logger';

export function getClient(
accessToken: string,
accessToken: string | null,
consumerKey: string,
headers: any,
) {
Expand Down Expand Up @@ -74,7 +74,7 @@ export function getClient(
export class GraphQLClientFactory {
url: string;
constructor(
accessToken: string,
accessToken: string | null,
consumerKey: string,
private headers: any,
) {
Expand Down
2 changes: 1 addition & 1 deletion servers/v3-proxy-api/src/routes/ActionsRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ type SendActionResult = {
export class ActionsRouter {
protected client: GraphQLClientFactory;
constructor(
accessToken: string,
accessToken: string | null,
consumerKey: string,
headers: Request['headers'],
) {
Expand Down
9 changes: 9 additions & 0 deletions servers/v3-proxy-api/src/routes/v3Send.integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,15 @@ describe('v3/send', () => {
});
expect(response.status).toEqual(400);
});
it('makes request without access token (cookie auth)', async () => {
const response = await request(app)
.post('/v3/send')
.send({
consumer_key: 'test',
actions: [{ action: 'add', url: 'http://domain.com/path' }],
});
expect(response.status).toEqual(200);
});
it('returns 400 if proper identifiers are not included', async () => {
const response = await request(app)
.post('/v3/send')
Expand Down
3 changes: 2 additions & 1 deletion servers/v3-proxy-api/src/routes/validations/SendSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Schema } from 'express-validator';
import { MaybeAction } from './SendActionValidators';

export type V3SendParams = {
access_token: string;
access_token?: string;
consumer_key: string;
actions: MaybeAction[];
};
Expand All @@ -17,6 +17,7 @@ export type V3SendParams = {
*/
export const V3SendSchemaPost: Schema = {
access_token: {
optional: true,
isString: true,
notEmpty: {
errorMessage: '`access_token` cannot be empty',
Expand Down
Loading