-
Notifications
You must be signed in to change notification settings - Fork 1
feat: oidc #149
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
Merged
Merged
feat: oidc #149
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
193a327
feat: add evidence manipulation on controls directly
gusfcarvalho 6875e2e
feat: oidc
gusfcarvalho f7cd543
fix: improvements on login and errors
gusfcarvalho f2b1d54
chore: merge main
gusfcarvalho 3ab395d
fix: lint
gusfcarvalho 250201b
fix: copilot comments
gusfcarvalho b397d59
fix: add reactivity to draw_io
gusfcarvalho f84c41e
fix: copilot fixes
gusfcarvalho 403ea4a
fix: lint
gusfcarvalho c33d8e2
fix: copilot issues
gusfcarvalho File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| @import 'tailwindcss'; | ||
| @import 'tailwindcss-primeui'; | ||
| @plugin '@tailwindcss/typography'; | ||
|
|
||
| @custom-variant dark (&:is(.dark &)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| <script setup lang="ts"> | ||
| import { computed } from 'vue'; | ||
| import { useTheme } from '@/composables/useTheme'; | ||
|
|
||
| const { theme, toggleTheme, useSystemValue } = useTheme(); | ||
|
|
||
| const iconPath = computed(() => { | ||
| if (theme.value === 'dark') { | ||
| // Font Awesome style sun icon | ||
| return 'M256 152c-57.34 0-104 46.66-104 104s46.66 104 104 104s104-46.66 104-104s-46.66-104-104-104m0-88c13.25 0 24-10.75 24-24V24c0-13.25-10.75-24-24-24s-24 10.75-24 24v16c0 13.25 10.75 24 24 24m0 368c-13.25 0-24 10.75-24 24v16c0 13.25 10.75 24 24 24s24-10.75 24-24v-16c0-13.25-10.75-24-24-24m200-200h-16c-13.25 0-24 10.75-24 24s10.75 24 24 24h16c13.25 0 24-10.75 24-24s-10.75-24-24-24m-368 24c0-13.25-10.75-24-24-24H48c-13.25 0-24 10.75-24 24s10.75 24 24 24h16c13.25 0 24-10.75 24-24m282.5-141.1l11.3-11.3c9.37-9.37 9.37-24.57 0-33.94s-24.57-9.37-33.94 0l-11.3 11.3c-9.37 9.37-9.37 24.57 0 33.94s24.57 9.37 33.94 0m-226.5 226.5l-11.3 11.3c-9.37 9.37-9.37 24.57 0 33.94s24.57 9.37 33.94 0l11.3-11.3c9.37-9.38 9.37-24.58 0-33.95s-24.57-9.37-33.94.01m0-226.5c9.37-9.37 9.37-24.57 0-33.94l-11.3-11.3c-9.37-9.37-24.57-9.37-33.94 0s-9.37 24.57 0 33.94l11.3 11.3c9.37 9.37 24.57 9.37 33.94 0m226.5 226.5c-9.37 9.37-9.37 24.57 0 33.94l11.3 11.3c9.37 9.37 24.57 9.37 33.94 0s9.37-24.57 0-33.94l-11.3-11.3c-9.37-9.38-24.57-9.38-33.94 0'; | ||
| } | ||
| // Font Awesome style moon icon | ||
| return 'M279.135 512c78.962 0 151.253-35.925 199.061-92.792c7.079-8.327-.639-20.748-11.367-18.223C291.054 443.25 184.313 326.844 184.313 192c0-77.649 38.621-146.196 97.221-187.374c9.206-6.4 5.382-20.713-5.68-22.493C271.798 .579 267.891 0 263.903 0C118.134 0 0 114.639 0 256s118.134 256 263.903 256c5.09 0 10.142-.174 15.232-.51'; | ||
| }); | ||
|
|
||
| const handleClick = () => { | ||
| toggleTheme(); | ||
| }; | ||
|
|
||
| const handleContextMenu = (event: MouseEvent) => { | ||
| event.preventDefault(); | ||
| useSystemValue(); | ||
| }; | ||
gusfcarvalho marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| </script> | ||
|
|
||
| <template> | ||
| <button | ||
| class="fixed bottom-5 right-5 z-50 h-12 w-12 rounded-full bg-white/80 dark:bg-slate-800/80 shadow-lg border border-gray-200 dark:border-slate-700 flex items-center justify-center hover:scale-105 transition-transform" | ||
| @click="handleClick" | ||
| @contextmenu="handleContextMenu" | ||
| type="button" | ||
| aria-label="Toggle theme" | ||
| title="Left click toggles theme. Right click matches system preference." | ||
| > | ||
gusfcarvalho marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| <svg | ||
| class="h-6 w-6 text-gray-700 dark:text-amber-300 transition-colors" | ||
| viewBox="0 0 512 512" | ||
| fill="currentColor" | ||
| aria-hidden="true" | ||
| > | ||
| <path :d="iconPath" /> | ||
| </svg> | ||
| </button> | ||
| </template> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| import { ref } from 'vue'; | ||
| import { useConfigStore } from '@/stores/config'; | ||
| import { useGuestApi } from '@/composables/axios'; | ||
|
|
||
| export interface OIDCProvider { | ||
| name: string; | ||
| displayName: string; | ||
| enabled: boolean; | ||
gusfcarvalho marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| iconUrl?: string; | ||
| } | ||
|
|
||
| export function useOIDC() { | ||
| const configStore = useConfigStore(); | ||
| const providers = ref<OIDCProvider[]>([]); | ||
| const isLoading = ref(false); | ||
| const error = ref<string | null>(null); | ||
|
|
||
| const { execute: fetchProviders, data: providersData } = useGuestApi< | ||
| OIDCProvider[] | ||
| >('/api/auth/sso/providers', { method: 'GET' }, { immediate: false }); | ||
|
|
||
| const loadProviders = async () => { | ||
| isLoading.value = true; | ||
| error.value = null; | ||
| try { | ||
| await fetchProviders(); | ||
| const fetchedProviders = providersData.value ?? []; | ||
| providers.value = fetchedProviders.filter( | ||
| (provider) => provider.enabled !== false, | ||
| ); | ||
| } catch (_error) { | ||
| console.error('Failed to load SSO providers:'); | ||
| error.value = 'Failed to load SSO providers'; | ||
| providers.value = []; | ||
gusfcarvalho marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } finally { | ||
| isLoading.value = false; | ||
| } | ||
| }; | ||
|
|
||
| const initiateLogin = async (providerName: string) => { | ||
| const provider = providers.value.find( | ||
| (p) => p.name === providerName && p.enabled !== false, | ||
| ); | ||
| if (!provider) { | ||
| const unavailableMessage = 'Selected SSO provider is not available.'; | ||
| error.value = unavailableMessage; | ||
| throw new Error(unavailableMessage); | ||
| } | ||
| let config; | ||
| try { | ||
| config = await configStore.getConfig(); | ||
| } catch (err) { | ||
| error.value = 'Failed to initiate SSO login'; | ||
gusfcarvalho marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| throw err instanceof Error ? err : new Error('SSO init failed'); | ||
| } | ||
| window.location.href = `${config.API_URL}/api/auth/sso/${provider.name}`; | ||
gusfcarvalho marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }; | ||
|
|
||
| return { | ||
| providers, | ||
| isLoading, | ||
| error, | ||
| loadProviders, | ||
| initiateLogin, | ||
| }; | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.