Skip to content

Commit

Permalink
chore: general improvements
Browse files Browse the repository at this point in the history
- Improved environment variables naming
- Added .gitkeep to nextjs-fullstack `certs/` directory
- Fixed function naming in the `LogoutButton` component
  • Loading branch information
pisitpr-bidbax committed Sep 7, 2023
1 parent 1ccc549 commit 42088a4
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ public async Task<JsonWebKeySet> GetJwksAsync()
public async Task<TokenValidationResult> ValidateIdTokenAsync(string token)
{
// The audience claim in the ID token must match the merchant's client id.
var clientId = _configuration["CLIENT_ID"]
?? throw new InvalidOperationException("Missing configuration key CLIENT_ID");
var clientId = _configuration["BANKID_CLIENT_ID"]
?? throw new InvalidOperationException("Missing configuration key BANKID_CLIENT_ID");

var configuration = await GetOidcConfigurationAsync();
var jwks = await GetJwksAsync();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ public async Task<string> AcquireTokenAsync()

var configuration = await GetOidcConfigurationAsync();

var clientId = _configuration["CLIENT_ID"];
var clientSecret = _configuration["CLIENT_SEC"];
var clientId = _configuration["BANKID_CLIENT_ID"];
var clientSecret = _configuration["BANKID_CLIENT_SECRET"];
var scope = _configuration["BANKID_SCOPE"];

var body = new FormUrlEncodedContent(new[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
}
},
"BANKID_OPENID_CONFIGURATION_URI": "https://auth.current.bankid.no/auth/realms/current/.well-known/openid-configuration",
"CLIENT_ID": "string client id",
"CLIENT_SEC": "string client",
"BANKID_CLIENT_ID": "[replace with the provided client id]",
"BANKID_CLIENT_SECRET": "[replace with the provided client secret]",
"BANKID_BIOMETRICS_OPENID_CONFIGURATION_URI": "https://current.aletheia-test.idtech.no/.well-known/openid-configuration",
"BANKID_SCOPE": "openid permissions/client permissions/ciba",
"BANKID_TOKEN_GRANT_TYPE": "urn:openid:params:grant-type:ciba",
Expand Down
4 changes: 2 additions & 2 deletions example-code-flow/nextjs-fullstack/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ NEXTAUTH_SECRET="[openssl rand -hex 32]"
# The OpenID configuration URI of your OIDC provider.
NEXTAUTH_PROVIDER_CONFIGURATION="https://auth.current.bankid.no/auth/realms/current/.well-known/openid-configuration"
# Your application's Client ID.
NEXTAUTH_CLIENT_ID="yourapplication-bankid-current"
BANKID_CLIENT_ID="yourapplication-bankid-current"
# Your application's Client Secret.
NEXTAUTH_CLIENT_SECRET="secret"
BANKID_CLIENT_SECRET="secret"
3 changes: 2 additions & 1 deletion example-code-flow/nextjs-fullstack/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@ next-env.d.ts
.idea
*.iml

certs/
certs/*
!certs/.gitkeep
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ const handler = NextAuth({
scope: "openid profile nnin_altsub",
},
},
clientId: process.env.NEXTAUTH_CLIENT_ID,
clientSecret: process.env.NEXTAUTH_CLIENT_SECRET,
clientId: process.env.BANKID_CLIENT_ID,
clientSecret: process.env.BANKID_CLIENT_SECRET,
idToken: true,
checks: ["pkce", "state", "nonce"],
profile(profile) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { getCsrfToken } from "next-auth/react";

export default function LogoutButton() {
const handleLogin = async () => {
const handleLogout = async () => {
// TODO: handle error?
const res = await fetch(`/api/auth/signout/bid`, {
method: "post",
Expand All @@ -19,7 +19,7 @@ export default function LogoutButton() {
};
return (
<button
onClick={handleLogin}
onClick={handleLogout}
className="bg-background-light hover:bg-background-light-hover text-text-light text-lg font-medium px-6 py-2 rounded-full"
>
Log out
Expand Down

0 comments on commit 42088a4

Please sign in to comment.