penpot / penpot

Penpot: The open-source design tool for design and code collaboration
https://penpot.app
Mozilla Public License 2.0
32.3k stars 1.61k forks source link

feature: Auto-Login with OpenID #2550

Open fullheart opened 1 year ago

fullheart commented 1 year ago

Is your feature request related to a problem? Please describe.

At the moment we need a extra click to login with an OpenID Provider by clicking on Button OpenID. This extra click is not needed, when this feature request get implemented.

Describe the solution you'd like.

To speed-up the login process with an OpenID Provider, it would be create to activate auto-login with a new env variable. With this approach users must not click extra on OpenId Button.

A great reference to implement this feature, is the implementation in the open source project BookStack: https://www.bookstackapp.com/docs/admin/oidc-auth/ . They provide a AUTH_AUTO_INITIATE env variable. When this variable is set to true, the login process automatically starts, when login page is visited.

Describe alternatives you've considered.

I workaround this missing features in our organisation by "hacking" the docker container like that:

custom_config.js

var penpotFlags = "[OUR_PENPOT_FLAGS]"

function waitUntilDomAvailable(selector, callback) {
    const domNode = document.querySelector(selector)
    if (!domNode) {
        setTimeout(function() {
            waitUntilDomAvailable(selector, callback)
        }, 200)
    } else {
        callback(domNode)
    }
}
const buttonSelector = ".auth-buttons a.btn-primary"
waitUntilDomAvailable(buttonSelector, function(button) {
    const isRedirectionFromLogout = document.referrer === '[OUR_PENPOT_DOMAIN]'
    if (!isRedirectionFromLogout) {
        // Auto login
        button.click()
        button.setAttribute('disabled', 'disabled');
    }
})

docker-compose.yml

---
version: "3.5"

networks:
  penpot:

services:
  penpot-frontend:
    image: "penpotapp/frontend:latest"
    [...]

    volumes:
      [...]
      - type: bind
        source: ./custom_config.js
        target: /var/www/app/js/config.js
[...]

Additional context

No response

niwinz commented 1 year ago

Looks interesting, thanks.

fullheart commented 1 year ago

Great! Here some further information how BookStack implemented this feature (mentioned open-source project in description):

hirunatan commented 1 year ago

Closing due to inactivity. Please reopen it if necessary.

fullheart commented 1 year ago

Hi @hirunatan

Please re-open this issue, because this feature is still missing.

Thanks