Skip to content

Commit 7694773

Browse files
robkooperlmarini
andauthored
add headers when calling /api/me (#172)
* add headers when calling /api/me Same data is now returned as headers, these can be used when using clowder as an authentication call in nginx/traefik etc. * update CHANGELOG Co-authored-by: Luigi Marini <[email protected]>
1 parent 547ae34 commit 7694773

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/)
55
and this project adheres to [Semantic Versioning](http://semver.org/).
66

7+
## Unreleased
8+
9+
### Changed
10+
- `/api/me` will now return some of the same information as response headers.
11+
712
## 1.14.1 - 2021-02-02
813

914
- Google will no longer work as login provider, we are working on this issue [#157](https://github.com/clowder-framework/clowder/issues/157).

app/api/Users.scala

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,15 @@ class Users @Inject()(users: UserService, events: EventService) extends ApiContr
2424
*/
2525
def getUser() = AuthenticatedAction { implicit request =>
2626
request.user match {
27-
case Some(identity) => Ok(userToJSON(identity))
27+
case Some(identity) => {
28+
Ok(userToJSON(identity)).withHeaders(
29+
"X-User-ID" -> identity.id.stringify,
30+
"X-User-FirstName" -> identity.firstName,
31+
"X-User-LastName" -> identity.lastName,
32+
"X-User-FullName" -> identity.fullName,
33+
"X-User-Email" -> identity.email.getOrElse("")
34+
)
35+
}
2836
case None => Unauthorized("Not authenticated")
2937
}
3038
}

0 commit comments

Comments
 (0)