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

[Feature Request] Auth with Plex #14

Open
flying-sausages opened this issue Dec 10, 2020 · 8 comments
Open

[Feature Request] Auth with Plex #14

flying-sausages opened this issue Dec 10, 2020 · 8 comments
Assignees
Labels
enhancement New feature or request

Comments

@flying-sausages
Copy link
Contributor

Is your feature request related to a problem? Please describe.
It would be nice to be able to auth with Plex in order to not let anyone see what films you've got in your libraries.
You could also use this to pre-fill names for the users and get some nice pictures if they have them set up

Describe the solution you'd like
Use Plex SSO and check if the machine ID matches the server

Describe alternatives you've considered
using a reverse proxy with some other SSO/Auth mechanism

Additional context
N/A

@LukeChannings
Copy link
Owner

Notes for future me:

  • The sign-in endpoint is plex.tv/api/v2/users/signin
  • It takes a { login: string, password: string, rememberMe: boolean, verificationCode?: string }
  • It returns code 1029 if a verification code is required ({"errors":[{"code":1029,"message":"Please enter the verification code"}]}), or 1001 if the username / password are incorrect.
  • When successful, it sets a plex_tv_auth cookie and the following shape:
    interface PlexSigninResponse {
        id:                      number;
        uuid:                    string;
        username:                string;
        title:                   string;
        email:                   string;
        locale:                  null;
        emailOnlyAuth:           boolean;
        hasPassword:             boolean;
        protected:               boolean;
        thumb:                   string;
        authToken:               string;
        mailingListStatus:       string;
        mailingListActive:       boolean;
        scrobbleTypes:           string;
        country:                 string;
        subscription:            PurpleSubscription;
        subscriptionDescription: string;
        restricted:              boolean;
        anonymous:               null;
        home:                    boolean;
        guest:                   boolean;
        homeSize:                number;
        homeAdmin:               boolean;
        maxHomeSize:             number;
        certificateVersion:      number;
        rememberExpiresAt:       number;
        profile:                 Profile;
        entitlements:            string[];
        roles:                   string[];
        subscriptions:           SubscriptionElement[];
        pastSubscriptions:       any[];
        trials:                  any[];
        services:                Service[];
        adsConsent:              boolean;
        adsConsentSetAt:         number;
        adsConsentReminderAt:    number;
        twoFactorEnabled:        boolean;
        backupCodesCreated:      boolean;
    }
    
    interface Profile {
        autoSelectAudio:              boolean;
        defaultAudioLanguage:         string;
        defaultSubtitleLanguage:      string;
        autoSelectSubtitle:           number;
        defaultSubtitleAccessibility: number;
        defaultSubtitleForced:        number;
    }
    
    interface Service {
        identifier: string;
        endpoint:   string;
        token?:     string;
        status:     Status;
        secret?:    string;
    }
    
    enum Status {
        Online = "online",
    }
    
    interface PurpleSubscription {
        active:         boolean;
        subscribedAt:   Date;
        status:         string;
        paymentService: string;
        plan:           string;
        features:       string[];
    }
    
    interface SubscriptionElement {
        id:       null;
        mode:     string;
        renewsAt: null;
        endsAt:   null;
        type:     string;
        transfer: null;
        state:    string;
    }

@flying-sausages
Copy link
Contributor Author

I think it would be good to think of some use cases before just authing everything

  • multiple users with plex accounts andn having access to the same plex server
  • multiple users where one or more users do not have direct access to the plex server (e.g. watching in person wih users who do)
  • ..?

I guess it would make sense to keep a way for account-less people to join an existing room.
It makes no sense for users who don't have an account to be able to make rooms either (how are they gonna watch?).

@LukeChannings LukeChannings added the enhancement New feature or request label Dec 11, 2020
@Teeko7
Copy link

Teeko7 commented Dec 11, 2020

I think it would be good to think of some use cases before just authing everything

  • multiple users with plex accounts andn having access to the same plex server
  • multiple users where one or more users do not have direct access to the plex server (e.g. watching in person wih users who do)
  • ..?

I guess it would make sense to keep a way for account-less people to join an existing room.
It makes no sense for users who don't have an account to be able to make rooms either (how are they gonna watch?).

  • Preventing restricted accounts/users from seeing media they cannot play (e.g. my kids are "home users" underneath my account with restrictions based on ratings)

@Nelinski
Copy link

I'd love to have an auth system in place. It's the one thing stopping me from adding it to my reverse proxy to be "public". Two user cases I can think of:

  • Hide your media library from random people accessing your reverse proxy
  • Limit access to media to certain age groups. E.g. if the kids want to pick a film and can't decide, they can get film suggestions that are suitable to them.

@rouke-broersma
Copy link

It takes a { login: string, password: string, rememberMe: boolean, verificationCode?: string }

It would probably be better to use an application/oauth flow instead of having to put your username/password into moviematch to then pass on to plex.

@LukeChannings
Copy link
Owner

Here's how I've implemented the auth flow:

Screen.Recording.2021-02-21.at.22.31.08.mov

If you use 2FA Plex's login page will take care of it.

@Teeko7
Copy link

Teeko7 commented Feb 22, 2021

Does this handle home users? or only logging in using the plex account?

@LukeChannings
Copy link
Owner

Only logging in with a Plex account at the moment, although the dev branch is far from ready at the moment (still working on filters).

Finding out that the user is on the same network as the Plex server might need DNS-SD, which isn't something I can do in a web app.

You might need to log in with the server owner's Plex account to be able to use a home user, but I'll have to look into it more if I get time.

@LukeChannings LukeChannings self-assigned this Mar 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants