Skip to content
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

User Name and Login instead of niuaId in User List. #57

Open
ThamSunc opened this issue Mar 8, 2024 · 3 comments
Open

User Name and Login instead of niuaId in User List. #57

ThamSunc opened this issue Mar 8, 2024 · 3 comments

Comments

@ThamSunc
Copy link

ThamSunc commented Mar 8, 2024

When managing Users I got some thing weird in the user list. It shows niuaId under user email and login while displaying nothing under the name.

image

And when we go to the "Edit user" menu, we can't change any of them under User Information might be caused by the Synced via Auth Proxy

image

I assume it's kind of bugs. Is there any way to figure out to fix it?
at least we can see First Name in the Name field

@ThamSunc
Copy link
Author

Anyone could help to figure out the way?
@mure
@ChrisStrykesAgain
@haworthia
@gergo-papp
@rfriedma

@mure
Copy link
Collaborator

mure commented Apr 9, 2024

@ThamSunc

This is not a bug—it's the expected behavior for the way we authenticate SL users in Grafana using the auth proxy mode. We set a header in the NI web server before proxying requests to Grafana to let it know which user is making the request. So the only thing Grafana knows about our users is their ID.

It looks like you can set a X-WEBAUTH-NAME header as well to tell Grafana the name of the user. The USER_NAME variable may be available similar to the REMOTE_USER variable in the web server conf. So it could be possible, but no one has ever tried it before.

@ThamSunc
Copy link
Author

ThamSunc commented Apr 24, 2024

Hi @mure

It looks like you can set a X-WEBAUTH-NAME header as well to tell Grafana the name of the user. The USER_NAME variable may be available similar to the REMOTE_USER variable in the web server conf. So it could be possible, but no one has ever tried it before.

Thank you for your reply,

NI Web Server fails to restart with error message Variable 'USER_NAME' does not exist

So, Where can I find the list of variable provided by NI Web Server and/or NI SystemLink ?

Here is what I've done:

I've defined the optional headers in Grafana's custom.ini file accordingly as bellow:

[auth.proxy]
enabled = true
header_name = X-Remote-User
header_property = username
auto_sign_up = true
;sync_ttl = 60
;whitelist = 192.168.1.1, 192.168.2.1
# Optionally define more headers to sync other user attributes
# Example `headers = Name:X-WEBAUTH-NAME Role:X-WEBAUTH-ROLE Email:X-WEBAUTH-EMAIL Groups:X-WEBAUTH-GROUPS`
headers = Name:X-WEBAUTH-NAME Email:X-WEBAUTH-EMAIL 
# Read the auth proxy docs for details on what the setting below enables
;enable_login_token = false

And add the RequestHeader set X-WEBAUTH-NAME expr=%{USER_NAME} in the 75_grafana.conf file

LoadModule proxy_module ${MODULES_PATH}/mod_proxy.so
LoadModule proxy_http_module ${MODULES_PATH}/mod_proxy_http.so
LoadModule proxy_wstunnel_module ${MODULES_PATH}/mod_proxy_wstunnel.so

<Location "/grafana">
  # Use RewriteEngine to handle websocket connection upgrades
  RewriteEngine On
  RewriteCond %{HTTP:Connection} Upgrade [NC]
  RewriteCond %{HTTP:Upgrade} websocket [NC]
  RewriteRule proxy:http://127.0.0.1:3000/grafana/(.*) ws://127.0.0.1:3000/grafana/$1 [P,L]
  RequestHeader set X-Remote-User expr=%{REMOTE_USER}
  RequestHeader set X-WEBAUTH-NAME expr=%{USER_NAME}

  AuthNIApiKeyTranslateUsers On
  RequestHeader set X-NI-Api-Key expr=%{API_KEY} 
 

  Use NIAuthnEnableBrowsers
  Require valid-user
  # preserve Host header to avoid cross-origin problems
  ProxyPreserveHost on
  # proxy to Grafana
  ProxyPass          http://127.0.0.1:3000/grafana
  ProxyPassReverse   http://127.0.0.1:3000/grafana
</Location>

Then I restart Both NI Web Server and Grafana

However the NI Web Server fail to start with error Variable 'USER_NAME' does not exist as the following message:

The web server failed to start.
AH00526: Syntax error on line 12 of C:/Program Files/National Instruments/Shared/Web Server/conf/conf.d/75_grafana.conf:
Can't parse value expression : Variable 'USER_NAME' does not exist

So, Where can I find the list of variable provided by NI Web Server and/or NI SystemLink ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants