codifyglobal / peertube-plugin-auth-oauth2

A PeerTube server plugin that adds support for external authentication via an OAuth 2.0 provider.
10 stars 5 forks source link

Sanitize username #6

Open unrainer opened 2 years ago

unrainer commented 2 years ago

Hi, my peertube instance is linked to an oauth2 server by plugin auth-oauth2, so new users can sign up this way. Unfortunately the oauth-server policies for usernames allow some special characters e.g. john-doe.whoever, which are not allowed for username in peertube. Is there a way, to sanitize the username value before sending it to peertube, or to configure peertube to accept special characters?

Thx a lot for any suggestions!

lpotcgi commented 2 years ago

Hi, I encountered the same issue. How can I simply replace all not allowed characters by HTML escape corresponding values at the beginning of the oAuth connection?

john-doe.whoever => john_045doe.whoever john_doe.whoever => john_095doe.whoever john#doe.whoever => john_035doe.whoever john_095doe.whoever => john_095095doe.whoever

It's a little bit ugly.

A more simple approach could be to transform '-' by '' and to forbid all other special characters including ''. In fact, '-' is very common, all other special characters are rare.

This PR works fine for me : https://github.com/codifyglobal/peertube-plugin-auth-oauth2/pull/4

Thanks a lot.