Can I pass Username instead of Firstname + Lastname to shiny prox

712 Views Asked by At

I am using Shinyproxy with Keycloak and read the username with userName <- Sys.getenv("SHINYPROXY_USERNAME")

Unfortunately I receive a concatenation of FirstName and LastName, which is not unique.

I would like to have the username in SHINYPROXY_USERNAME. Is this a Keycloak configuration issue?

1

There are 1 best solutions below

0
On BEST ANSWER

From documentation

proxy.keycloak.name-attribute: name of the attribute to use as the user's name; 
     one of name (default, current behaviour), preferred_username, nickname or email

in the default keycloak token mapping preferred_username is the username of the keycloak user.

So set in your application.yml

 keycloak:
    ...
    name-attribute: preferred_username

If this does not work, you can always remove existing token mappers for name (a few token mappers a pre defined in client_scopes) and create a token mapper with the following config

  • type: User Property
  • property: username
  • Token Claim Name: name
  • ID/Access/User-Info: on

Now Keycloak tokens will contain a attribute name with the value of users username