Skip to content

Commit ec81214

Browse files
committed
feat: add nonce claim support to oidc server
1 parent 0e6bcf9 commit ec81214

11 files changed

Lines changed: 77 additions & 35 deletions

File tree

frontend/src/lib/hooks/oidc.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export type OIDCValues = {
44
client_id: string;
55
redirect_uri: string;
66
state: string;
7+
nonce: string;
78
};
89

910
interface IuseOIDCParams {
@@ -13,7 +14,7 @@ interface IuseOIDCParams {
1314
missingParams: string[];
1415
}
1516

16-
const optionalParams: string[] = ["state"];
17+
const optionalParams: string[] = ["state", "nonce"];
1718

1819
export function useOIDCParams(params: URLSearchParams): IuseOIDCParams {
1920
let compiled: string = "";
@@ -26,6 +27,7 @@ export function useOIDCParams(params: URLSearchParams): IuseOIDCParams {
2627
client_id: params.get("client_id") ?? "",
2728
redirect_uri: params.get("redirect_uri") ?? "",
2829
state: params.get("state") ?? "",
30+
nonce: params.get("nonce") ?? "",
2931
};
3032

3133
for (const key of Object.keys(values)) {

frontend/src/pages/authorize-page.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ export const AuthorizePage = () => {
9898
client_id: props.client_id,
9999
redirect_uri: props.redirect_uri,
100100
state: props.state,
101+
nonce: props.nonce,
101102
});
102103
},
103104
mutationKey: ["authorize", props.client_id],
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ALTER TABLE "oidc_codes" DROP COLUMN "nonce";
2+
ALTER TABLE "oidc_tokens" DROP COLUMN "nonce";
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ALTER TABLE "oidc_codes" ADD COLUMN "nonce" TEXT DEFAULT "";
2+
ALTER TABLE "oidc_tokens" ADD COLUMN "nonce" TEXT DEFAULT "";

internal/controller/oidc_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ func (controller *OIDCController) Token(c *gin.Context) {
296296
return
297297
}
298298

299-
tokenRes, err := controller.oidc.GenerateAccessToken(c, client, entry.Sub, entry.Scope)
299+
tokenRes, err := controller.oidc.GenerateAccessToken(c, client, entry)
300300

301301
if err != nil {
302302
tlog.App.Error().Err(err).Msg("Failed to generate access token")

internal/repository/models.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/repository/oidc_queries.sql.go

Lines changed: 34 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)