-
-
Notifications
You must be signed in to change notification settings - Fork 13
Endpoint user/challenger/recover #636
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
base: main
Are you sure you want to change the base?
Changes from all commits
b946edd
890e57b
222db1f
db24e2c
3265416
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| module Fission.Web.API.User.Challenge.Types (Routes (..)) where | ||
|
|
||
| import Fission.Challenge.Types | ||
|
|
||
| import Fission.Web.API.Prelude | ||
|
|
||
| import Fission.User.Username.Types | ||
|
|
||
| import qualified Fission.Web.API.Auth.Types as Auth | ||
|
|
||
| data Routes mode = Routes | ||
| { recover :: | ||
| mode | ||
| :- "recover" | ||
| :> Summary "Return challenge for account recovery" | ||
| -- | ||
| :> Capture "Username" Username | ||
| -- | ||
| :> Auth.HigherOrder | ||
| :> Post '[JSON] Challenge | ||
| } | ||
| deriving Generic | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| module Fission.Web.Server.Handler.User.Challenge (handler) where | ||
|
|
||
| import Servant | ||
| import Servant.Server.Generic | ||
|
|
||
| import Fission.Prelude | ||
|
|
||
| import qualified Fission.Web.API.User.Challenge.Types as Challenge | ||
|
|
||
| import Fission.Web.Server.Authorization.Types | ||
| import qualified Fission.Web.Server.Error as Web.Err | ||
| import Fission.Web.Server.Models | ||
| import qualified Fission.Web.Server.RecoveryChallenge.Creator.Class as RecoveryChallenge | ||
| import Fission.Web.Server.User.Retriever.Class as User | ||
|
|
||
| handler :: | ||
| ( RecoveryChallenge.Creator m | ||
| , User.Retriever m | ||
| , MonadThrow m | ||
| , MonadLogger m | ||
| , MonadTime m | ||
| ) | ||
| => Challenge.Routes (AsServerT m) | ||
| handler = Challenge.Routes {..} | ||
| where | ||
| recover username Authorization { about = Entity userId _ } = do | ||
| Entity _ User { } <- Web.Err.ensureMaybe couldntFindUser =<< getByUsername username | ||
| now <- currentTime | ||
| challenge <- RecoveryChallenge.create userId now | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. However, here we don't check any other property about the authentication, right? So if I read this correctly, doesn't this allow any fission user to issue & get a challenge for any other fission user? E.g. a malicious actor could create a new fission account, and then use their UCAN to run a request
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ahh thanks for catching that! I'll admit I have a fairly tenuous understanding of this codebase. This new endpoint was cobbled together from bits of various other ones I saw in the repo 😅 Looking at some other examples, I think I see how to add that validation here. I'll get this fixed today!
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the goal, actually? How should the auth gating work for that endpoint?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The current approach we're taking is:
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I should add that the
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That sound awesome and exactly like what I'd expect. Let's go 🚀 |
||
| return challenge | ||
|
|
||
| where | ||
| couldntFindUser = | ||
| err422 { errBody = "Couldn't find a user with this username" } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| name: fission-web-server | ||
| version: "2.21.0.0" | ||
| version: "2.21.0.1" | ||
| category: API | ||
| author: | ||
| - Brooklyn Zelenka | ||
|
|
@@ -15,7 +15,7 @@ maintainer: | |
| - [email protected] | ||
| - [email protected] | ||
| - [email protected] | ||
| copyright: © 2021 Fission Internet Software Services for Open Networks Inc. | ||
| copyright: © 2023 Fission Internet Software Services for Open Networks Inc. | ||
| license: AGPL-3.0-or-later | ||
| license-file: LICENSE | ||
| github: fission-suite/fission | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line ensures that only fission-registered accounts (and UCANs that are delegated from fission-registered accounts) can make these requests 👍