-
Couldn't load subscription status.
- Fork 11
feat: generate key one time #992
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
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
6d03aba
feat: generate key one time
elibosley 9d48c70
fix: find by key, not ID
elibosley 5e215c4
fix: create connect key
elibosley 4e5542f
fix: update tests
elibosley d57b24e
fix: connect key role
elibosley 0709b85
fix: only instantiate service one time
elibosley 003e5fc
fix: swap to placeholder key
elibosley 208193f
feat: faster failure logic
elibosley 3daa14d
fix: use placeholder in test API key
elibosley a1c4620
fix: clearer error messaging
elibosley f3bb7dc
feat: rename api key resource back to api_key
elibosley f8f348e
fix: extra spacing in config.ts
elibosley fe6717e
fix: excess spacing in api-key.service
elibosley a471c35
fix: remove usage of Role.UPC
elibosley 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
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
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,10 @@ | ||
| { | ||
| "createdAt": "2024-12-20T15:05:55.336Z", | ||
| "description": "API key for Connect user", | ||
| "id": "d166bf8b-3615-444a-8932-c460b2132ba3", | ||
| "key": "_______________________LOCAL_API_KEY_HERE_________________________", | ||
| "name": "Connect", | ||
| "roles": [ | ||
| "connect" | ||
| ] | ||
| } |
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
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
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,42 @@ | ||
| """ | ||
| Available resources for permissions | ||
| """ | ||
| enum Resource { | ||
| api_key | ||
| array | ||
| cloud | ||
| config | ||
| connect | ||
| connect__remote_access | ||
| customizations | ||
| dashboard | ||
| disk | ||
| display | ||
| docker | ||
| flash | ||
| info | ||
| logs | ||
| me | ||
| network | ||
| notifications | ||
| online | ||
| os | ||
| owner | ||
| permission | ||
| registration | ||
| servers | ||
| services | ||
| share | ||
| vars | ||
| vms | ||
| welcome | ||
| } | ||
|
|
||
| """ | ||
| Available roles for API keys and users | ||
| """ | ||
| enum Role { | ||
| admin | ||
| connect | ||
| guest | ||
| } |
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,33 @@ | ||
| import { minigraphLogger } from '@app/core/log'; | ||
| import { getters, store } from '@app/store/index'; | ||
| import { updateUserConfig } from '@app/store/modules/config'; | ||
| import { FileLoadStatus } from '@app/store/types'; | ||
| import { ApiKeyService } from '@app/unraid-api/auth/api-key.service'; | ||
|
|
||
| export const createLocalApiKeyForConnectIfNecessary = async () => { | ||
| if (getters.config().status !== FileLoadStatus.LOADED) { | ||
| minigraphLogger.error('Config file not loaded, cannot create local API key'); | ||
| return; | ||
| } | ||
|
|
||
| const { remote } = getters.config(); | ||
| const apiKeyService = new ApiKeyService(); | ||
| // If the remote API Key is set and the local key is either not set or not found on disk, create a key | ||
| if (remote.apikey && (!remote.localApiKey || !(await apiKeyService.findByKey(remote.localApiKey)))) { | ||
| minigraphLogger.debug('Creating local API key for Connect'); | ||
| // Create local API key | ||
| const localApiKey = await apiKeyService.createLocalConnectApiKey(); | ||
|
|
||
| if (localApiKey?.key) { | ||
| store.dispatch( | ||
| updateUserConfig({ | ||
| remote: { | ||
| localApiKey: localApiKey.key, | ||
| }, | ||
| }) | ||
| ); | ||
| } else { | ||
| throw new Error('Failed to create local API key - no key returned'); | ||
| } | ||
| } | ||
| }; | ||
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 was deleted.
Oops, something went wrong.
Oops, something went wrong.
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.