feat: test auth

This commit is contained in:
thomas
2024-03-29 21:29:52 +01:00
parent 73a81f4831
commit 18b1dc0a70
18 changed files with 1749 additions and 386 deletions

View File

@@ -1,11 +1,21 @@
import { toHexString } from '../../utils/encrypt';
export const prerender = false;
const GITHUB_OAUTH_AUTHORIZE_URL = 'https://github.com/login/oauth/authorize';
export async function GET({params, redirect}) {
export async function GET({url, redirect}) {
console.log('Authorize request', params);
const myUrl = new URL(url);
const params = new URLSearchParams(myUrl.search);
const redirectUrl = params.get('redirect_uri');
const redirect_uri = 'http://localhost:4321/auth/localized'
const { GITHUB_CLIENT_ID } = import.meta.env;
const oauthParams = new URLSearchParams({ client_id:'Iv1.711903007f608691' , redirect_uri, state: 'lqsksqd' });
const redirect_uri = 'http://localhost:4321/auth/authorized'
const state = toHexString(redirectUrl);
const oauthParams = new URLSearchParams({ client_id:GITHUB_CLIENT_ID , redirect_uri, state });
return redirect(`${GITHUB_OAUTH_AUTHORIZE_URL}?${oauthParams}`, 302)
}