Skip to content

Commit

Permalink
OidcEncryption#generateMasterPassword check file system support pos…
Browse files Browse the repository at this point in the history
…ix before setting permission (helidon-io#8296)

* check file system support posix before setting permission

Signed-off-by: tvallin <thibault.vallin@oracle.com>

* Add debug logging

Signed-off-by: tvallin <thibault.vallin@oracle.com>

* review changes

Signed-off-by: tvallin <thibault.vallin@oracle.com>

* do not set file permission on windows

Signed-off-by: tvallin <thibault.vallin@oracle.com>

---------

Signed-off-by: tvallin <thibault.vallin@oracle.com>
  • Loading branch information
tvallin authored and hrstoyanov committed Feb 23, 2024
1 parent 13024e2 commit bde033b
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, 2023 Oracle and/or its affiliates.
* Copyright (c) 2021, 2024 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -82,7 +82,9 @@ private static char[] generateMasterPassword() {
String password = UUID.randomUUID().toString();
try {
Files.writeString(path, password, StandardCharsets.UTF_8, StandardOpenOption.CREATE_NEW);
Files.setPosixFilePermissions(path, Set.of(PosixFilePermission.OWNER_READ, PosixFilePermission.OWNER_WRITE));
if (path.getFileSystem().supportedFileAttributeViews().contains("posix")) {
Files.setPosixFilePermissions(path, Set.of(PosixFilePermission.OWNER_READ, PosixFilePermission.OWNER_WRITE));
}
} catch (IOException e) {
throw new SecurityException("Failed to create OIDC secret " + path.toAbsolutePath(), e);
}
Expand Down

0 comments on commit bde033b

Please sign in to comment.