Skip to content

[FEATURE] Access controls for non-containerized apps #275

@mitchellkellett

Description

@mitchellkellett

Is your feature request related to a problem? Please describe.
I'd like to be able to protect non containerised, but proxied apps, by using groups from my oidc provider. For example, my solar system has a page where I can view the outputs etc, but has no authentication. So I proxy it through NPM (ie https://solar.example.com) and I'd like to have it protected with Tinyauth.

Describe the solution you'd like
A way to protect non containerised proxied apps by using groups. I'm thinking that we could add something like proxy_set_header X-Tinyauth-Groups: My-App-Users to the NPM config like in the below.

Describe alternatives you've considered
Currently, the only option I can see is to have it require an active account in my oidc provider because I'm not able to apply labels like I do to my containerised applications.

Additional context

# Root location
location / {
  # Pass the request to the app
  proxy_pass          $forward_scheme://$server:$port;
  
  # Tinyauth auth request
  auth_request /auth;
  error_page 401 = @tinyauth_login;
  
  # Pass the auth request headers
  auth_request_set $tinyauth_remote_user $upstream_http_remote_user;
  proxy_set_header remote-user $tinyauth_remote_user;
  auth_request_set $tinyauth_remote_email $upstream_http_remote_email;
  proxy_set_header remote-email $tinyauth_remote_email;
  auth_request_set $tinyauth_remote_name $upstream_http_remote_name;
  proxy_set_header remote-name $tinyauth_remote_name;
  auth_request_set $tinyauth_remote_groups $upstream_http_remote_groups;
  proxy_set_header remote-groups $tinyauth_remote_groups;
  
  # Standard proxy headers (these were missing)
  proxy_set_header Host $host;
  proxy_set_header X-Real-IP $remote_addr;
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  proxy_set_header X-Forwarded-Proto $scheme;
  proxy_set_header X-Forwarded-Scheme $scheme;
  
  # Additional proxy settings for better compatibility
  proxy_http_version 1.1;
  proxy_set_header Connection "";
  proxy_cache_bypass $http_upgrade;
  proxy_set_header Upgrade $http_upgrade;
  proxy_set_header Connection "upgrade";
}

# Tinyauth auth request
location /auth {
  # Pass request to tinyauth
  proxy_pass http://tinyauth-server-1:3000/api/auth/nginx;
  
  # Pass the request headers
  proxy_set_header X-Real-IP $remote_addr;
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  proxy_set_header X-Forwarded-Proto $scheme;
  proxy_set_header X-Forwarded-Host $http_host;
  proxy_set_header X-Forwarded-Uri $request_uri;

  # Pass required groups
  proxy_set_header X-Tinyauth-Groups: My-App-Users
}

# Tinyauth login redirect
location @tinyauth_login {
  return 302 https://auth.example.com/login?redirect_uri=$scheme://$http_host$request_uri;
}

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestpinnedThis issue is pinned

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions