-
Notifications
You must be signed in to change notification settings - Fork 89
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
feat(frontend, mock-ase): secure admin API with Hydra #2466
Conversation
9a9a215
to
ef7584f
Compare
✅ Deploy Preview for brilliant-pasca-3e80ec canceled.
|
@@ -284,13 +284,15 @@ export async function createWalletAddress( | |||
}) | |||
} | |||
|
|||
export async function createWalletAddressKey({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just formatting in this file
export async function setupFromSeed(config: Config): Promise<void> { | ||
const assets: Record<string, Asset> = {} | ||
for (const { code, scale, liquidity, liquidityThreshold } of config.seed | ||
.assets) { | ||
const { asset } = await createAsset(code, scale, liquidityThreshold) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just formatting in this file as well
@@ -24,251 +24,300 @@ import type { | |||
WithdrawAssetLiquidity, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This, and other files with the path /frontend/app/lib/api/*.server.ts
, will have messy diffs but all follow the same change: the query is now nested inside of a try-catch block, and the catch
block will catch the error, and if it is an Unauthenticated
Apollo Error, it will throw an error formatted for Remix instead.
@@ -21,195 +21,238 @@ import { | |||
type GetOutgoingPaymentVariables, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -22,202 +22,246 @@ import type { | |||
WithdrawPeerLiquidity, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -1,5 +1,5 @@ | |||
import { gql } from '@apollo/client' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -1,51 +1,60 @@ | |||
import { gql } from '@apollo/client' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -16,8 +13,8 @@ BigInt.prototype.toJSON = function (this: bigint) { | |||
return this.toString() | |||
} | |||
|
|||
if (!global.__apolloClient) { | |||
global.__apolloClient = new ApolloClient({ | |||
export function getApolloClient(token?: string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to re-instantiate the Apollo Client each time a request is made now, so that it is able to pick up whether or not an authorization token is present. Normal stuff for React apps, in those cases it just happens inside of a React element whenever the app state changes.
@@ -4,6 +4,7 @@ import { v4 } from 'uuid' | |||
import { LiquidityDialog } from '~/components/LiquidityDialog' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file, and other files in /app/routes/*.tsx
all generally involve modifying the Remix loader and/or action to retrieve the API auth token from the session and passing it to whatever API call it's making.
@@ -18,19 +18,25 @@ import { Button, ErrorPanel, Input } from '~/components/ui' | |||
import { FeeType } from '~/generated/graphql' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -4,6 +4,7 @@ import { v4 } from 'uuid' | |||
import { LiquidityDialog } from '~/components/LiquidityDialog' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -1,5 +1,6 @@ | |||
import { json, type LoaderFunctionArgs } from '@remix-run/node' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -4,6 +4,7 @@ import { PageHeader } from '~/components' | |||
import { Button, Table } from '~/components/ui' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -4,6 +4,7 @@ import { PageHeader } from '~/components' | |||
import { Button, ErrorPanel, Input } from '~/components/ui' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
7da3d34
to
7ee7d1c
Compare
Changes proposed in this pull request
backend
that verifies the token with a request to the Hydra container.401
if invalid token, continues tonext()
if validUnauthorized
responses from the Apollo clientContext
Fixes #2218 and #2497.
Adds a Hydra container, a basic authorization flow for it, and a middleware in the API to check for a valid authorization token for a given API request.
Checklist
fixes #number