Add auth starter

This commit is contained in:
Tyler 2025-06-06 19:42:19 -04:00
parent 1c0c45841f
commit d6555ee216
Signed by: tyler
GPG Key ID: 03B27509E17EFDC8
15 changed files with 12890 additions and 18 deletions

View File

@ -1,19 +1,3 @@
# Agent
# Authenticated Nuxt starter
## Goals
- Oauth2 authentication with service
- Text interface for agent
- Nuxt UI for agent
- Agent with access to tools
- Access to a long term storage tool, configured as a local vectordb
- Access to a terminal scratch pad
- Access to ntfy for sending information to me
- Voice based interface
- Can use telnyx for interaction
- Can use ham?
- Single container
Reduced scope
- Text interface to ollama server that exists now, with oauth2

View File

24
ui/.gitignore vendored Normal file
View File

@ -0,0 +1,24 @@
# Nuxt dev/build outputs
.output
.data
.nuxt
.nitro
.cache
dist
# Node dependencies
node_modules
# Logs
logs
*.log
# Misc
.DS_Store
.fleet
.idea
# Local env files
.env
.env.*
!.env.example

75
ui/README.md Normal file
View File

@ -0,0 +1,75 @@
# Nuxt Minimal Starter
Look at the [Nuxt documentation](https://nuxt.com/docs/getting-started/introduction) to learn more.
## Setup
Make sure to install dependencies:
```bash
# npm
npm install
# pnpm
pnpm install
# yarn
yarn install
# bun
bun install
```
## Development Server
Start the development server on `http://localhost:3000`:
```bash
# npm
npm run dev
# pnpm
pnpm dev
# yarn
yarn dev
# bun
bun run dev
```
## Production
Build the application for production:
```bash
# npm
npm run build
# pnpm
pnpm build
# yarn
yarn build
# bun
bun run build
```
Locally preview production build:
```bash
# npm
npm run preview
# pnpm
pnpm preview
# yarn
yarn preview
# bun
bun run preview
```
Check out the [deployment documentation](https://nuxt.com/docs/getting-started/deployment) for more information.

20
ui/app.vue Normal file
View File

@ -0,0 +1,20 @@
<template>
<UApp>
<NuxtPage />
</UApp>
</template>
<script setup lang="ts">
import { onMounted, useAuth } from './.nuxt/imports';
// Get auth session data
const { getSession } = useAuth();
// Store JWT in local storage when it's available
onMounted(async () => {
const session = await getSession();
if (session?.accessToken) {
localStorage.setItem('jwt', session.accessToken);
}
});
</script>

33
ui/nuxt.config.ts Normal file
View File

@ -0,0 +1,33 @@
// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
modules: ['@nuxt/ui', '@sidebase/nuxt-auth'],
css: [
],
compatibilityDate: '2025-05-15',
devtools: { enabled: true },
ui: {
theme: {
colors: ['primary', 'error', 'secondary', 'info', 'success', 'warning'],
transitions: true
},
fonts: false
},
auth: {
globalAppMiddleware: true,
provider: {
type: 'authjs',
trustHost: false,
defaultProvider: 'default',
addDefaultCallbackUrl: true
},
isEnabled: true,
disableServerSideAuth: false,
sessionRefresh: {
enablePeriodically: true,
enableOnWindowFocus: true
},
pages: {
signIn: '/auth/signin'
}
}
})

12624
ui/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

22
ui/package.json Normal file
View File

@ -0,0 +1,22 @@
{
"name": "nuxt-app",
"private": true,
"type": "module",
"scripts": {
"build": "nuxt build",
"dev": "nuxt dev",
"generate": "nuxt generate",
"preview": "nuxt preview",
"postinstall": "nuxt prepare"
},
"dependencies": {
"@nuxt/ui": "^3.1.3",
"@nuxtjs/tailwindcss": "^7.0.0-beta.0",
"@sidebase/nuxt-auth": "^0.10.1",
"next-auth": "~4.21.1",
"nuxi": "^3.25.1",
"nuxt": "^3.17.5",
"vue": "^3.5.16",
"vue-router": "^4.5.1"
}
}

17
ui/pages/auth/signin.vue Normal file
View File

@ -0,0 +1,17 @@
<template>
<div>
<!-- This page will automatically redirect to the default provider -->
</div>
</template>
<script setup lang="ts">
import { onMounted } from 'vue';
import { useAuth } from '#imports';
const { signIn } = useAuth();
// Automatically redirect to the default provider when the page loads
onMounted(() => {
signIn('default');
});
</script>

21
ui/pages/index.vue Normal file
View File

@ -0,0 +1,21 @@
<template>
<button @click="login()">
login
</button>
<p> You are {{ authStatus }}</p>
<p v-if="user">Email: {{ user.email }}</p>
</template>
<script setup lang="ts">
const { signIn, signOut, status, data } = useAuth();
const authStatus = status.value;
const user = data.value?.user;
function login() {
signIn('default');
}
</script>

BIN
ui/public/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

2
ui/public/robots.txt Normal file
View File

@ -0,0 +1,2 @@
User-Agent: *
Disallow:

View File

@ -0,0 +1,43 @@
import {NuxtAuthHandler} from '#auth'
export default NuxtAuthHandler({
secret: "my-cool-secret",
providers: [
{
id: "default",
name: "default",
type: "oauth",
wellKnown: "",
clientId: "",
clientSecret: "",
authorization: {
params: {
scope: "openid email profile"
}
},
idToken: true,
// checks: [ "pkce", "state" ],
profile(profile) {
return {
id: profile.sub,
name: profile.name,
email: profile.email,
}
}
}
],
callbacks: {
async jwt({ token, account }) {
// Persist the access token to the token right after signin
if (account) {
token.accessToken = account.access_token;
}
return token;
},
async session({ session, token }) {
// Send properties to the client
session.accessToken = token.accessToken;
return session;
}
}
});

3
ui/server/tsconfig.json Normal file
View File

@ -0,0 +1,3 @@
{
"extends": "../.nuxt/tsconfig.server.json"
}

4
ui/tsconfig.json Normal file
View File

@ -0,0 +1,4 @@
{
// https://nuxt.com/docs/guide/concepts/typescript
"extends": "./.nuxt/tsconfig.json"
}