mirror of
https://codeberg.org/MarkusThielker/next-ory.git
synced 2025-04-18 00:21:18 +00:00
NORY-46: add client auth mechanism
This commit is contained in:
parent
8fbab67060
commit
b70afcf16c
2 changed files with 50 additions and 4 deletions
|
@ -15,6 +15,7 @@ import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/com
|
||||||
import { useRouter } from 'next/navigation';
|
import { useRouter } from 'next/navigation';
|
||||||
import { Checkbox } from '@/components/ui/checkbox';
|
import { Checkbox } from '@/components/ui/checkbox';
|
||||||
import { Minus } from 'lucide-react';
|
import { Minus } from 'lucide-react';
|
||||||
|
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select';
|
||||||
|
|
||||||
interface CreateClientFormProps {
|
interface CreateClientFormProps {
|
||||||
action: (data: z.infer<typeof clientFormSchema>) => Promise<AxiosResponse<OAuth2Client, any>>;
|
action: (data: z.infer<typeof clientFormSchema>) => Promise<AxiosResponse<OAuth2Client, any>>;
|
||||||
|
@ -60,13 +61,13 @@ export function CreateClientForm({ action }: CreateClientFormProps) {
|
||||||
setRedirectUris([...redirectUris, '']);
|
setRedirectUris([...redirectUris, '']);
|
||||||
};
|
};
|
||||||
|
|
||||||
const removeRedirectUri = (index) => {
|
const removeRedirectUri = (index: number) => {
|
||||||
const updatedRedirectUris = redirectUris.filter((_, i) => i !== index);
|
const updatedRedirectUris = redirectUris.filter((_, i) => i !== index);
|
||||||
setRedirectUris(updatedRedirectUris);
|
setRedirectUris(updatedRedirectUris);
|
||||||
form.setValue('redirect_uris', updatedRedirectUris);
|
form.setValue('redirect_uris', updatedRedirectUris);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleInputChange = (index, event) => {
|
const handleInputChange = (index: number, event: any) => {
|
||||||
const updatedRedirectUris = [...redirectUris];
|
const updatedRedirectUris = [...redirectUris];
|
||||||
updatedRedirectUris[index] = event.target.value;
|
updatedRedirectUris[index] = event.target.value;
|
||||||
setRedirectUris(updatedRedirectUris);
|
setRedirectUris(updatedRedirectUris);
|
||||||
|
@ -165,8 +166,8 @@ export function CreateClientForm({ action }: CreateClientFormProps) {
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
{form.errors?.redirect_uris && form.errors.redirect_uris[index] && (
|
{form.formState.errors?.redirect_uris && form.formState.errors.redirect_uris[index] && (
|
||||||
<FormMessage>{form.errors.redirect_uris[index].message}</FormMessage>
|
<FormMessage>{form.formState.errors.redirect_uris[index].message}</FormMessage>
|
||||||
)}
|
)}
|
||||||
</FormItem>
|
</FormItem>
|
||||||
</div>
|
</div>
|
||||||
|
@ -341,6 +342,50 @@ export function CreateClientForm({ action }: CreateClientFormProps) {
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
|
<Card>
|
||||||
|
<CardHeader>
|
||||||
|
<CardTitle>
|
||||||
|
Client authentication mechanism
|
||||||
|
</CardTitle>
|
||||||
|
<CardDescription>
|
||||||
|
Set the client authentication method for the token endpoint. By default the client
|
||||||
|
credentials must be sent in the body of an HTTP POST. This option can also specify for
|
||||||
|
sending the credentials encoded in the HTTP Authorization header or by using JSON Web
|
||||||
|
Tokens. Specify none for public clients (native apps, mobile apps) which can not have
|
||||||
|
secrets.
|
||||||
|
</CardDescription>
|
||||||
|
</CardHeader>
|
||||||
|
<CardContent className="space-y-4">
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name="token_endpoint_auth_method"
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel>Authentication method</FormLabel>
|
||||||
|
<Select onValueChange={field.onChange} defaultValue={field.value}>
|
||||||
|
<FormControl>
|
||||||
|
<SelectTrigger>
|
||||||
|
<SelectValue placeholder="Select an authentication mechanism"/>
|
||||||
|
</SelectTrigger>
|
||||||
|
</FormControl>
|
||||||
|
<SelectContent>
|
||||||
|
<SelectItem value="client_secret_post">HTTP Body <span
|
||||||
|
className="text-sm text-gray-500 ml-2">(client_secret_post)</span></SelectItem>
|
||||||
|
<SelectItem value="client_secret_basic">HTTP Basic Authorization<span
|
||||||
|
className="text-sm text-gray-500 ml-2">(client_secret_basic)</span></SelectItem>
|
||||||
|
<SelectItem value="private_key_jwt">JWT Authentication <span
|
||||||
|
className="text-sm text-gray-500 ml-2">(private_key_jwt)</span></SelectItem>
|
||||||
|
<SelectItem value="none">None <span
|
||||||
|
className="text-sm text-gray-500 ml-2">(none)</span></SelectItem>
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
<FormMessage/>
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
|
||||||
<div className="space-x-2">
|
<div className="space-x-2">
|
||||||
<Button type="button" variant="outline" onClick={() => {
|
<Button type="button" variant="outline" onClick={() => {
|
||||||
router.back();
|
router.back();
|
||||||
|
|
|
@ -13,4 +13,5 @@ export const clientFormSchema = z.object({
|
||||||
grant_types: z.array(z.string()),
|
grant_types: z.array(z.string()),
|
||||||
response_types: z.array(z.string()),
|
response_types: z.array(z.string()),
|
||||||
token_endpoint_auth_method: z.string(),
|
token_endpoint_auth_method: z.string(),
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue