Skip to content
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
Empty file removed .gitkeep
Empty file.
9 changes: 9 additions & 0 deletions recipes/vue-vite/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[*.{js,jsx,mjs,cjs,ts,tsx,mts,cts,vue}]
charset = utf-8
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

end_of_line = lf
max_line_length = 100
1 change: 1 addition & 0 deletions recipes/vue-vite/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto eol=lf
30 changes: 30 additions & 0 deletions recipes/vue-vite/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
.DS_Store
dist
dist-ssr
coverage
*.local

/cypress/videos/
/cypress/screenshots/

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

*.tsbuildinfo
7 changes: 7 additions & 0 deletions recipes/vue-vite/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

{
"$schema": "https://json.schemastore.org/prettierrc",
"semi": false,
"singleQuote": true,
"printWidth": 100
}
9 changes: 9 additions & 0 deletions recipes/vue-vite/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"recommendations": [
"Vue.volar",
"vitest.explorer",
"dbaeumer.vscode-eslint",
"EditorConfig.EditorConfig",
"esbenp.prettier-vscode"
]
}
105 changes: 105 additions & 0 deletions recipes/vue-vite/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# Asgardeo Auth Vue.js SDK Usage Example (Single Page Application)

This sample is developed to demonstrate the basic usage of the Asgardeo Auth Vue.js SDK.

## Getting Started

### Prerequisites
- `Node.js` (version 20 or above).

### Register an Application
//TODO

Make sure to add `http://localhost:5173` as a Redirect URL and also add it under allowed origins.

### Download the Sample
//TODO

### Configure the Sample

Update the authentication configuration in your `main.ts` file with your registered app details.

**Note:** You will need to paste in the `client ID` generated for the application you registered.

```typescript
import "./assets/main.css";
import { createApp } from "vue";
import App from "./App.vue";
import router from "./router";
import { asgardeoPlugin } from "./auth/authprovider";

const app = createApp(App);

app.use(router);
app.use(asgardeoPlugin, {
signInRedirectURL: "http://localhost:5173/",
signOutRedirectURL: "http://localhost:5173/",
clientID: "<ADD_CLIENT_ID_HERE>",
baseUrl: "https://api.asgardeo.io/t/<org_name>",
});

app.mount("#app");
```

### Run the Application

```bash
npm install && npm run dev
```

The app should open at [`http://localhost:5173`](http://localhost:5173)

### Change the Application's Development Server Port

By default, the Vite development server runs on port `5173`. In case you wish to change this to something else, follow the steps below.

1. Update the port in your Vite configuration file (`vite.config.js` or `vite.config.ts`):
```javascript
export default defineConfig({
// Other config options...
server: {
port: YOUR_PREFERRED_PORT
}
})
```

2. Update the `signInRedirectURL` & `signOutRedirectURL` in `main.ts` to match your new port.

3. Go to the Asgardeo Console and navigate to the protocol tab of your application:
- Update the Authorized Redirect URL.
- Update the Allowed Origins.

## Using the Auth Plugin

The Asgardeo Auth plugin is available throughout your Vue application. Here's how to use it in your components:

```vue
<script setup>
import { useAsgardeo } from '@asgardeo/vue';

const { isAuthenticated, signIn, signOut, getBasicUserInfo } = useAsgardeo();
</script>

<template>
<div>
<button v-if="!isAuthenticated" @click="signIn">Login</button>
<button v-else @click="signOut">Logout</button>
</div>
</template>
```

//TODO

## Contribute

Please read [Contributing to the Code Base](../../CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests to us.

### Reporting Issues

We encourage you to report issues, improvements, and feature requests by creating [Github Issues](https://github.com/asgardeo/web-ui-sdks/issues).

Important: Please be advised that security issues must be reported to [email protected], not as GitHub issues, in order to reach the proper audience. We strongly advise following the WSO2 Security Vulnerability Reporting Guidelines when reporting security issues.

## License

This project is licensed under the Apache License 2.0. See the [LICENSE](../../LICENSE) file for details.
1 change: 1 addition & 0 deletions recipes/vue-vite/env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="vite/client" />
45 changes: 45 additions & 0 deletions recipes/vue-vite/eslint.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
* Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
*
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import pluginVue from 'eslint-plugin-vue'
import { defineConfigWithVueTs, vueTsConfigs } from '@vue/eslint-config-typescript'
import pluginVitest from '@vitest/eslint-plugin'
import skipFormatting from '@vue/eslint-config-prettier/skip-formatting'

// To allow more languages other than `ts` in `.vue` files, uncomment the following lines:
// import { configureVueProject } from '@vue/eslint-config-typescript'
// configureVueProject({ scriptLangs: ['ts', 'tsx'] })
// More info at https://github.com/vuejs/eslint-config-typescript/#advanced-setup

export default defineConfigWithVueTs(
{
name: 'app/files-to-lint',
files: ['**/*.{ts,mts,tsx,vue}'],
},
{
name: 'app/files-to-ignore',
ignores: ['**/dist/**', '**/dist-ssr/**', '**/coverage/**'],
},
pluginVue.configs['flat/essential'],
vueTsConfigs.recommended,
{
...pluginVitest.configs.recommended,
files: ['src/**/__tests__/*'],
},
skipFormatting,
)
31 changes: 31 additions & 0 deletions recipes/vue-vite/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!--
* Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
*
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
-->

<!doctype html>
<html lang="">
<head>
<meta charset="UTF-8" />
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vue Sample</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
</body>
</html>
42 changes: 42 additions & 0 deletions recipes/vue-vite/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"name": "vue-sample",
"version": "0.0.0",
"private": true,
"type": "module",
"scripts": {
"dev": "vite",
"build": "run-p type-check \"build-only {@}\" --",
"preview": "vite preview",
"test:unit": "vitest",
"build-only": "vite build",
"type-check": "vue-tsc --build",
"lint": "eslint . --fix",
"format": "prettier --write src/"
},
"dependencies": {
"vue": "^3.5.13",
"vue-router": "^4.5.0"
},
"devDependencies": {
"@tsconfig/node22": "^22.0.0",
"@types/jsdom": "^21.1.7",
"@types/node": "^22.13.4",
"@vitejs/plugin-vue": "^5.2.1",
"@vitest/eslint-plugin": "1.1.31",
"@vue/eslint-config-prettier": "^10.2.0",
"@vue/eslint-config-typescript": "^14.4.0",
"@vue/test-utils": "^2.4.6",
"@vue/tsconfig": "^0.7.0",
"eslint": "^9.20.1",
"eslint-plugin-vue": "^9.32.0",
"jiti": "^2.4.2",
"jsdom": "^26.0.0",
"npm-run-all2": "^7.0.2",
"prettier": "^3.5.1",
"typescript": "5.1.6",
"vite": "^6.1.0",
"vite-plugin-vue-devtools": "^7.7.2",
"vitest": "^3.0.5",
"vue-tsc": "^2.2.2"
}
}
Binary file added recipes/vue-vite/public/favicon.ico
Binary file not shown.
89 changes: 89 additions & 0 deletions recipes/vue-vite/src/App.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<!--
* Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
*
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
-->

<script setup lang="ts">
import { RouterView } from 'vue-router'
</script>

<template>
<RouterView />
</template>

<style scoped>
header {
line-height: 1.5;
max-height: 100vh;
}

.logo {
display: block;
margin: 0 auto 2rem;
}

nav {
width: 100%;
font-size: 12px;
text-align: center;
margin-top: 2rem;
}

nav a.router-link-exact-active {
color: var(--color-text);
}

nav a.router-link-exact-active:hover {
background-color: transparent;
}

nav a {
display: inline-block;
padding: 0 1rem;
border-left: 1px solid var(--color-border);
}

nav a:first-of-type {
border: 0;
}

@media (min-width: 1024px) {
header {
display: flex;
place-items: center;
padding-right: calc(var(--section-gap) / 2);
}

.logo {
margin: 0 2rem 0 0;
}

header .wrapper {
display: flex;
place-items: flex-start;
flex-wrap: wrap;
}

nav {
text-align: left;
margin-left: -1rem;
font-size: 1rem;

padding: 1rem 0;
margin-top: 1rem;
}
}
</style>
Loading
Loading