-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0614ae8
commit f47cd1e
Showing
5 changed files
with
48 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { keycloak, refreshToken } from "@/app/api/auth/[...nextauth]/keycloak"; | ||
|
||
import { logger } from "@/utils/logger"; | ||
import { AuthOptions } from "next-auth"; | ||
|
||
const log = logger.child({ module: "auth" }); | ||
export const authOptions: AuthOptions = { | ||
providers: [keycloak], | ||
callbacks: { | ||
async jwt({ token, account }) { | ||
// Persist the OAuth access_token and or the user id to the token right after signin | ||
if (account) { | ||
log.trace("account present, saving new token"); | ||
// Save the access token and refresh token in the JWT on the initial login | ||
return { | ||
access_token: account.access_token, | ||
expires_at: account.expires_at, | ||
refresh_token: account.refresh_token, | ||
email: token.email, | ||
name: token.name, | ||
picture: token.picture, | ||
sub: token.sub, | ||
}; | ||
} | ||
|
||
return refreshToken(token); | ||
}, | ||
async session({ session, token }) { | ||
// Send properties to the client, like an access_token from a provider. | ||
log.trace(token, "Creating session from token"); | ||
return { | ||
...session, | ||
error: token.error, | ||
accessToken: token.access_token, | ||
}; | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters