Skip to content

Commit

Permalink
Trim security config usernames and roles
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartwdouglas committed Dec 16, 2020
1 parent c2376a7 commit 5ef182c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import io.quarkus.runtime.annotations.ConfigItem;
import io.quarkus.runtime.annotations.ConfigPhase;
import io.quarkus.runtime.annotations.ConfigRoot;
import io.quarkus.runtime.annotations.ConvertWith;
import io.quarkus.runtime.configuration.TrimmedStringConverter;

/**
* Configuration information used to populate a {@linkplain org.wildfly.security.auth.realm.SimpleMapBackedSecurityRealm}
Expand Down Expand Up @@ -35,13 +37,15 @@ public class MPRealmRuntimeConfig {
* See <a href="#embedded-users">Embedded Users</a>.
*/
@ConfigItem(defaultValueDocumentation = "none")
@ConvertWith(TrimmedStringConverter.class)
public Map<String, String> users;

/**
* The realm roles user1=role1,role2,...\nuser2=role1,role2,... mapping
* See <a href="#embedded-roles">Embedded Roles</a>.
*/
@ConfigItem(defaultValueDocumentation = "none")
@ConvertWith(TrimmedStringConverter.class)
public Map<String, String> roles;

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

import io.quarkus.runtime.annotations.ConfigGroup;
import io.quarkus.runtime.annotations.ConfigItem;
import io.quarkus.runtime.annotations.ConvertWith;
import io.quarkus.runtime.configuration.TrimmedStringConverter;

@ConfigGroup
public class PolicyConfig {
Expand All @@ -12,5 +14,6 @@ public class PolicyConfig {
* The roles that are allowed to access resources protected by this policy
*/
@ConfigItem
@ConvertWith(TrimmedStringConverter.class)
public List<String> rolesAllowed;
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
quarkus.security.users.embedded.enabled=true
quarkus.security.users.embedded.users.john=john
quarkus.security.users.embedded.roles.john=employees
quarkus.security.users.embedded.users.mary=mary
quarkus.security.users.embedded.roles.mary=managers
#note that the spaces after the usernames and roles are deliberate
#to verify that they are trimmed correctly
quarkus.security.users.embedded.users.john=john
quarkus.security.users.embedded.roles.john=employees
quarkus.security.users.embedded.users.mary=mary
quarkus.security.users.embedded.roles.mary=managers
quarkus.security.users.embedded.users.poul=poul
quarkus.security.users.embedded.roles.poul=interns
quarkus.security.users.embedded.plain-text=true
Expand Down

0 comments on commit 5ef182c

Please sign in to comment.