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

Add verification for password oauth token #10800

Merged
merged 14 commits into from
Jan 29, 2024
Merged

Conversation

nanaya
Copy link
Collaborator

@nanaya nanaya commented Dec 13, 2023

# reissue verification code
POST api/v2/session/verify/reissue

# verify token
POST api/v2/session/verify
parameter: verification_key (string)

On /me endpoint response, there's a new attribute session_verified.

Additionally, notification server will also send verification event when the verification link is opened ({ "event": "verified" })

@nanaya nanaya changed the title Add oauth verification for password token Add verification for password oauth token Dec 13, 2023
@nanaya nanaya force-pushed the oauth-verification-2 branch 3 times, most recently from 4b58c63 to d619d45 Compare December 15, 2023 12:05
@nanaya nanaya marked this pull request as ready for review December 15, 2023 12:21
@nanaya nanaya marked this pull request as draft December 15, 2023 12:25
@nanaya nanaya force-pushed the oauth-verification-2 branch from d619d45 to c4b0b31 Compare December 15, 2023 12:34
@nanaya nanaya marked this pull request as ready for review December 15, 2023 12:34
Copy link
Collaborator

@notbakaneko notbakaneko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A verified session sending verification_key to verify-session probably shouldn't be issuing a new verification code? 🤔

app/Models/OAuth/Token.php Show resolved Hide resolved
notbakaneko
notbakaneko previously approved these changes Dec 19, 2023
Copy link
Collaborator

@notbakaneko notbakaneko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reminder ppy/osu-notification-server#55 also should be deployed after this is deployed.

@peppy
Copy link
Member

peppy commented Dec 21, 2023

Additionally, notification server will also send verification event when the verification link is opened

Given that we don't yet have any setup for notification server in the game yet, is it fine to ignore this for now? Do we need to poll or something to handle the scenario?

@nanaya
Copy link
Collaborator Author

nanaya commented Dec 21, 2023

ignoring it would confuse users. I guess a token status endpoint could be added...

@peppy
Copy link
Member

peppy commented Dec 21, 2023

Cancel that, we do have support for notification websocket handling (see https://github.com/ppy/osu/blob/27c497145f87449ac17c08796fc57026d3129f2e/osu.Game/Online/Notifications/WebSocket/WebSocketNotificationsClientConnector.cs#L16-L45)

But work on this will likely happen early next year from the client side, so let's leave this PR in limbo for now.

@peppy peppy self-requested a review December 21, 2023 09:32
@peppy peppy self-assigned this Dec 21, 2023
@bdach
Copy link
Contributor

bdach commented Jan 23, 2024

I would like to get started on this client-side, but I'm not sure I get what fits where exactly, so I'm gonna have a few questions here.

  • From what I can gather, the basic flow is as follows:

    sequenceDiagram
        participant osu
        participant external web browser
        participant osu-web
        participant redis
        participant osu-notification-server
    
        osu ->>+ osu-web: GET /api/v2/users/me
        osu-web -->>- osu: 200 OK<br>{ ..., session_verified: false }
    
        note right of osu: User received verification e-mail
    
        alt verification code entered via client
    
            osu ->>+ osu-web: POST /api/v2/session/verify?verification_key=...
            osu-web -->>- osu: 200 OK
    
        else verification link clicked
    
            external web browser ->>+ osu-web: GET /home/account/verify?key=...
            osu-web ->>+ osu-notification-server: UserSessionEvent::newVerified->broadcast()
            osu-notification-server -->>- osu-web: ACK
            osu-web -->>- external web browser: 200 OK
    
            osu-notification-server --) osu: { "event": "verified" }
    
        end
    
    Loading

    Do I have that right?

  • In this comment, the following was stated:

    Basically there will be a case where web will let us know via a response to any API request that we need verification, which will cause the client to bring up the prompt.

    Is this really the case here? Do I need to be potentially handling (re-)verification on any response? From source it kinda appears to me that it's only scoped to GET /api/v2/users/me but I may well be wrong.

  • Do I need to be handling token revocation? As in, if a UserSessionEvent::newLogout() event is broadcast, do I need to be doing anything? Is that even something that can happen for a client token right now?

@bdach bdach assigned bdach and unassigned peppy Jan 23, 2024
@nanaya
Copy link
Collaborator Author

nanaya commented Jan 25, 2024

I would like to get started on this client-side, but I'm not sure I get what fits where exactly, so I'm gonna have a few questions here.

  • From what I can gather, the basic flow is as follows:

    Do I have that right?

seems mostly right. The newVerified event is always published regardless of the source. I don't think it matters much in the context of client though.

  • In this comment, the following was stated:

    Basically there will be a case where web will let us know via a response to any API request that we need verification, which will cause the client to bring up the prompt.

    Is this really the case here? Do I need to be potentially handling (re-)verification on any response? From source it kinda appears to me that it's only scoped to GET /api/v2/users/me but I may well be wrong.

mainly only POST requests will return verification required response (exceptions etc applies). It's the same as web at the moment.

  • Do I need to be handling token revocation? As in, if a UserSessionEvent::newLogout() event is broadcast, do I need to be doing anything? Is that even something that can happen for a client token right now?

a logout event means the session/token is no longer valid. One case would be when the user changes password (on web) it'll log out all other sessions and tokens.

technically even without handling it any further requests will be denied anyway but at least in osu-web a forced logout will be immediately applied.

@peppy peppy merged commit a6fea4e into ppy:master Jan 29, 2024
2 of 3 checks passed
@nanaya nanaya deleted the oauth-verification-2 branch February 27, 2024 11:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants