Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions src/routes/consent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@ router.get("/", csrfProtection, (req, res, next) => {
// This data will be available when introspecting the token. Try to avoid sensitive information here,
// unless you limit who can introspect tokens.
// accessToken: { foo: 'bar' },
// This data will be available in the ID token.
// idToken: { baz: 'bar' },
id_token: {
email: consentRequest.subject,
},
},
},
})
Expand Down
17 changes: 1 addition & 16 deletions src/routes/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,22 +91,7 @@ router.post("/", csrfProtection, (req, res, next) => {
)
}

// Let's check if the user provided valid credentials. Of course, you'd use a database or some third-party service
// for this!
if (!(req.body.email === "[email protected]" && req.body.password === "foobar")) {
// Looks like the user provided invalid credentials, let's show the ui again...

res.render("login", {
csrfToken: req.csrfToken(),
challenge: challenge,
error: "The username / password combination is not correct",
})

return
}

// Seems like the user authenticated! Let's tell hydra...

hydraAdmin
.getOAuth2LoginRequest({ loginChallenge: challenge })
.then((loginRequest) =>
Expand All @@ -115,7 +100,7 @@ router.post("/", csrfProtection, (req, res, next) => {
loginChallenge: challenge,
acceptOAuth2LoginRequest: {
// Subject is an alias for user ID. A subject can be a random string, a UUID, an email address, ....
subject: "[email protected]",
subject: req.body.email,

// This tells hydra to remember the browser and automatically authenticate the user in future requests. This will
// set the "skip" parameter in the other route to true on subsequent requests!
Expand Down
Loading