-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
325 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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
29 changes: 29 additions & 0 deletions
29
src/main/kotlin/dev/floofy/hazel/cli/commands/keystore/AddUserCommand.kt
This file contains 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,29 @@ | ||
/* | ||
* 🪶 hazel: Minimal, simple, and open source content delivery network made in Kotlin | ||
* Copyright 2022 Noel <[email protected]> | ||
* | ||
* Licensed 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. | ||
*/ | ||
|
||
package dev.floofy.hazel.cli.commands.keystore | ||
|
||
import com.github.ajalt.clikt.core.CliktCommand | ||
|
||
object AddUserCommand: CliktCommand( | ||
name = "add-user", | ||
help = "Adds a user to the keystore." | ||
) { | ||
override fun run() { | ||
println("soon:tm:") | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
src/main/kotlin/dev/floofy/hazel/cli/commands/keystore/KeystoreCommand.kt
This file contains 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,45 @@ | ||
/* | ||
* 🪶 hazel: Minimal, simple, and open source content delivery network made in Kotlin | ||
* Copyright 2022 Noel <[email protected]> | ||
* | ||
* Licensed 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. | ||
*/ | ||
|
||
package dev.floofy.hazel.cli.commands.keystore | ||
|
||
import com.github.ajalt.clikt.core.CliktCommand | ||
import com.github.ajalt.clikt.core.PrintHelpMessage | ||
import com.github.ajalt.clikt.core.subcommands | ||
|
||
object KeystoreCommand: CliktCommand( | ||
name = "keystore", | ||
invokeWithoutSubcommand = true, | ||
help = """ | ||
|The `keystore` command is the main management utility for managing Hazel's keystore. | ||
| | ||
|Hazel uses a Java keystore to handle secret key management, SSL certificates for the server, | ||
|and user persistence without bringing in an external database. | ||
| | ||
|To generate a keystore, you can run `hazel keystore generate` to create the keystore in the path | ||
|and you can load it using the `keystore.path` configuration key. | ||
""".trimMargin() | ||
) { | ||
init { | ||
subcommands(ListKeysCommand) | ||
} | ||
|
||
override fun run() { | ||
if (currentContext.invokedSubcommand == null) | ||
throw PrintHelpMessage(this, false) | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
src/main/kotlin/dev/floofy/hazel/cli/commands/keystore/ListKeysCommand.kt
This file contains 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 @@ | ||
/* | ||
* 🪶 hazel: Minimal, simple, and open source content delivery network made in Kotlin | ||
* Copyright 2022 Noel <[email protected]> | ||
* | ||
* Licensed 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. | ||
*/ | ||
|
||
package dev.floofy.hazel.cli.commands.keystore | ||
|
||
import dev.floofy.hazel.cli.abstractions.BaseKeystoreCommand | ||
|
||
object ListKeysCommand: BaseKeystoreCommand( | ||
"list", | ||
"List all the keys in the keystore." | ||
) { | ||
override fun run() { | ||
val keystore = wrapper() | ||
val keys = keystore.keys() | ||
|
||
for (key in keys) { | ||
val isUser = key.startsWith("users.") | ||
if (isUser) { | ||
val name = key.split(".").last() | ||
println("===> User $name | Use `hazel keystore update-pwd $name` to update their password,") | ||
println(" | or use `hazel keystore delete users.$name` to delete their account") | ||
println(" | in the keystore.") | ||
} else { | ||
println("===> Key $key") | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.