Functional Weave
Code in TypeScript

auth.oauth-sign-in@1.0.0

contracts.json

48,134 bytes · view raw

[
  {"fn":"beginSignIn","name":"oidc: discovers Google and builds the authorisation URL with PKCE and a nonce","provider":"oidc","env":{"SESSION_SECRET":"test-session-secret-0123456789abcdefghij","OIDC_ISSUER":"https://accounts.google.com","OIDC_CLIENT_ID":"fune-test-client.apps.googleusercontent.com","OIDC_CLIENT_SECRET":"test-secret-oidc"},"args":["https://app.acme.example/auth/callback","/dashboard"],"exchanges":[{"request":{"method":"GET","url":"https://accounts.google.com/.well-known/openid-configuration","headers":{"accept":"application/json"}},"response":{"status":200,"json":{"issuer":"https://accounts.google.com","authorization_endpoint":"https://accounts.google.com/o/oauth2/v2/auth","device_authorization_endpoint":"https://oauth2.googleapis.com/device/code","token_endpoint":"https://oauth2.googleapis.com/token","userinfo_endpoint":"https://openidconnect.googleapis.com/v1/userinfo","revocation_endpoint":"https://oauth2.googleapis.com/revoke","jwks_uri":"https://www.googleapis.com/oauth2/v3/certs","response_types_supported":["code","token","id_token","code token","code id_token","token id_token","code token id_token","none"],"subject_types_supported":["public"],"id_token_signing_alg_values_supported":["RS256"],"scopes_supported":["openid","email","profile"],"token_endpoint_auth_methods_supported":["client_secret_post","client_secret_basic"],"claims_supported":["aud","email","email_verified","exp","family_name","given_name","iat","iss","name","picture","sub"],"code_challenge_methods_supported":["plain","S256"],"grant_types_supported":["authorization_code","refresh_token","urn:ietf:params:oauth:grant-type:device_code","urn:ietf:params:oauth:grant-type:jwt-bearer"]}}}],"expect":{"url":"https://accounts.google.com/o/oauth2/v2/auth?response_type=code&client_id=fune-test-client.apps.googleusercontent.com&redirect_uri=https%3A%2F%2Fapp.acme.example%2Fauth%2Fcallback&scope=openid%20email%20profile&state=AAECAwQFBgcICQoLDA0ODw&nonce=MDEyMzQ1Njc4OTo7PD0-Pw&code_challenge=bIeEEJ0ry7gh7qIC3JSmluTwY9ojq4Xh5mey_Zok5bg&code_challenge_method=S256","cookie":"eyJ0Ijoic2lnbmluIiwicCI6Im9pZGMiLCJzdCI6IkFBRUNBd1FGQmdjSUNRb0xEQTBPRHciLCJ2IjoiRUJFU0V4UVZGaGNZR1JvYkhCMGVIeUFoSWlNa0pTWW5LQ2txS3l3dExpOCIsIm4iOiJNREV5TXpRMU5qYzRPVG83UEQwLVB3IiwidSI6Imh0dHBzOi8vYXBwLmFjbWUuZXhhbXBsZS9hdXRoL2NhbGxiYWNrIiwiciI6Ii9kYXNoYm9hcmQiLCJleHAiOjE3NjcyMjYyMDB9.MCLbr-gsVFiDAT9CxgKaQvm50ZMZsyJTm6bppSMKRd4","setCookie":"fune_signin=eyJ0Ijoic2lnbmluIiwicCI6Im9pZGMiLCJzdCI6IkFBRUNBd1FGQmdjSUNRb0xEQTBPRHciLCJ2IjoiRUJFU0V4UVZGaGNZR1JvYkhCMGVIeUFoSWlNa0pTWW5LQ2txS3l3dExpOCIsIm4iOiJNREV5TXpRMU5qYzRPVG83UEQwLVB3IiwidSI6Imh0dHBzOi8vYXBwLmFjbWUuZXhhbXBsZS9hdXRoL2NhbGxiYWNrIiwiciI6Ii9kYXNoYm9hcmQiLCJleHAiOjE3NjcyMjYyMDB9.MCLbr-gsVFiDAT9CxgKaQvm50ZMZsyJTm6bppSMKRd4; Path=/; HttpOnly; Secure; SameSite=Lax; Max-Age=600"}},
  {"fn":"beginSignIn","name":"oidc: a public Keycloak client, its own scopes, an endpoint that already has a query","provider":"oidc","env":{"SESSION_SECRET":"test-session-secret-0123456789abcdefghij","OIDC_ISSUER":"https://id.acme.example/realms/acme/","OIDC_CLIENT_ID":"acme-web","OIDC_SCOPES":"openid email"},"args":["http://localhost:3000/callback"],"exchanges":[{"request":{"method":"GET","url":"https://id.acme.example/realms/acme/.well-known/openid-configuration","headers":{"accept":"application/json"}},"response":{"status":200,"json":{"issuer":"https://id.acme.example/realms/acme","authorization_endpoint":"https://id.acme.example/realms/acme/protocol/openid-connect/auth?kc_idp_hint=staff","token_endpoint":"https://id.acme.example/realms/acme/protocol/openid-connect/token","userinfo_endpoint":"https://id.acme.example/realms/acme/protocol/openid-connect/userinfo","jwks_uri":"https://id.acme.example/realms/acme/protocol/openid-connect/certs","code_challenge_methods_supported":["plain","S256"]}}}],"expect":{"url":"https://id.acme.example/realms/acme/protocol/openid-connect/auth?kc_idp_hint=staff&response_type=code&client_id=acme-web&redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Fcallback&scope=openid%20email&state=AAECAwQFBgcICQoLDA0ODw&nonce=MDEyMzQ1Njc4OTo7PD0-Pw&code_challenge=bIeEEJ0ry7gh7qIC3JSmluTwY9ojq4Xh5mey_Zok5bg&code_challenge_method=S256","cookie":"eyJ0Ijoic2lnbmluIiwicCI6Im9pZGMiLCJzdCI6IkFBRUNBd1FGQmdjSUNRb0xEQTBPRHciLCJ2IjoiRUJFU0V4UVZGaGNZR1JvYkhCMGVIeUFoSWlNa0pTWW5LQ2txS3l3dExpOCIsIm4iOiJNREV5TXpRMU5qYzRPVG83UEQwLVB3IiwidSI6Imh0dHA6Ly9sb2NhbGhvc3Q6MzAwMC9jYWxsYmFjayIsInIiOm51bGwsImV4cCI6MTc2NzIyNjIwMH0.4XzdmaeyYQYoxWGW535vR-8HnoU4byri_ZMirKNo4-o","setCookie":"fune_signin=eyJ0Ijoic2lnbmluIiwicCI6Im9pZGMiLCJzdCI6IkFBRUNBd1FGQmdjSUNRb0xEQTBPRHciLCJ2IjoiRUJFU0V4UVZGaGNZR1JvYkhCMGVIeUFoSWlNa0pTWW5LQ2txS3l3dExpOCIsIm4iOiJNREV5TXpRMU5qYzRPVG83UEQwLVB3IiwidSI6Imh0dHA6Ly9sb2NhbGhvc3Q6MzAwMC9jYWxsYmFjayIsInIiOm51bGwsImV4cCI6MTc2NzIyNjIwMH0.4XzdmaeyYQYoxWGW535vR-8HnoU4byri_ZMirKNo4-o; Path=/; HttpOnly; Secure; SameSite=Lax; Max-Age=600"}},
  {"fn":"beginSignIn","name":"github: the authorisation URL needs no request","provider":"github","env":{"SESSION_SECRET":"test-session-secret-0123456789abcdefghij","GITHUB_CLIENT_ID":"Iv1.fune0test0client","GITHUB_CLIENT_SECRET":"test-secret-github"},"args":["https://app.acme.example/auth/callback","/settings?tab=profile"],"expect":{"url":"https://github.com/login/oauth/authorize?client_id=Iv1.fune0test0client&redirect_uri=https%3A%2F%2Fapp.acme.example%2Fauth%2Fcallback&scope=read%3Auser%20user%3Aemail&state=AAECAwQFBgcICQoLDA0ODw&code_challenge=bIeEEJ0ry7gh7qIC3JSmluTwY9ojq4Xh5mey_Zok5bg&code_challenge_method=S256","cookie":"eyJ0Ijoic2lnbmluIiwicCI6ImdpdGh1YiIsInN0IjoiQUFFQ0F3UUZCZ2NJQ1FvTERBME9EdyIsInYiOiJFQkVTRXhRVkZoY1lHUm9iSEIwZUh5QWhJaU1rSlNZbktDa3FLeXd0TGk4IiwibiI6Ik1ERXlNelExTmpjNE9UbzdQRDAtUHciLCJ1IjoiaHR0cHM6Ly9hcHAuYWNtZS5leGFtcGxlL2F1dGgvY2FsbGJhY2siLCJyIjoiL3NldHRpbmdzP3RhYj1wcm9maWxlIiwiZXhwIjoxNzY3MjI2MjAwfQ.QVYkjdnC2AE_16Xxx0tMrstW6P3dROGBXimfyFKUJUQ","setCookie":"fune_signin=eyJ0Ijoic2lnbmluIiwicCI6ImdpdGh1YiIsInN0IjoiQUFFQ0F3UUZCZ2NJQ1FvTERBME9EdyIsInYiOiJFQkVTRXhRVkZoY1lHUm9iSEIwZUh5QWhJaU1rSlNZbktDa3FLeXd0TGk4IiwibiI6Ik1ERXlNelExTmpjNE9UbzdQRDAtUHciLCJ1IjoiaHR0cHM6Ly9hcHAuYWNtZS5leGFtcGxlL2F1dGgvY2FsbGJhY2siLCJyIjoiL3NldHRpbmdzP3RhYj1wcm9maWxlIiwiZXhwIjoxNzY3MjI2MjAwfQ.QVYkjdnC2AE_16Xxx0tMrstW6P3dROGBXimfyFKUJUQ; Path=/; HttpOnly; Secure; SameSite=Lax; Max-Age=600"}},
  {"fn":"beginSignIn","name":"oidc: an issuer with no discovery document","provider":"oidc","env":{"SESSION_SECRET":"test-session-secret-0123456789abcdefghij","OIDC_ISSUER":"https://login.acme.example","OIDC_CLIENT_ID":"fune-test-client.apps.googleusercontent.com","OIDC_CLIENT_SECRET":"test-secret-oidc"},"args":["https://app.acme.example/auth/callback"],"exchanges":[{"request":{"method":"GET","url":"https://login.acme.example/.well-known/openid-configuration"},"response":{"status":404,"body":"Not Found"}}],"expectError":"oidc: https://login.acme.example/.well-known/openid-configuration answered 404; is OIDC_ISSUER right?"},
  {"fn":"beginSignIn","name":"oidc: a discovery document for another issuer is refused","provider":"oidc","env":{"SESSION_SECRET":"test-session-secret-0123456789abcdefghij","OIDC_ISSUER":"https://accounts.google.example","OIDC_CLIENT_ID":"fune-test-client.apps.googleusercontent.com","OIDC_CLIENT_SECRET":"test-secret-oidc"},"args":["https://app.acme.example/auth/callback"],"exchanges":[{"request":{"method":"GET","url":"https://accounts.google.example/.well-known/openid-configuration","headers":{"accept":"application/json"}},"response":{"status":200,"json":{"issuer":"https://accounts.google.com","authorization_endpoint":"https://accounts.google.com/o/oauth2/v2/auth","device_authorization_endpoint":"https://oauth2.googleapis.com/device/code","token_endpoint":"https://oauth2.googleapis.com/token","userinfo_endpoint":"https://openidconnect.googleapis.com/v1/userinfo","revocation_endpoint":"https://oauth2.googleapis.com/revoke","jwks_uri":"https://www.googleapis.com/oauth2/v3/certs","response_types_supported":["code","token","id_token","code token","code id_token","token id_token","code token id_token","none"],"subject_types_supported":["public"],"id_token_signing_alg_values_supported":["RS256"],"scopes_supported":["openid","email","profile"],"token_endpoint_auth_methods_supported":["client_secret_post","client_secret_basic"],"claims_supported":["aud","email","email_verified","exp","family_name","given_name","iat","iss","name","picture","sub"],"code_challenge_methods_supported":["plain","S256"],"grant_types_supported":["authorization_code","refresh_token","urn:ietf:params:oauth:grant-type:device_code","urn:ietf:params:oauth:grant-type:jwt-bearer"]}}}],"expectError":"oidc: the discovery document is for issuer https://accounts.google.com, not OIDC_ISSUER https://accounts.google.example"},
  {"fn":"beginSignIn","name":"oidc: scopes without openid","provider":"oidc","env":{"SESSION_SECRET":"test-session-secret-0123456789abcdefghij","OIDC_ISSUER":"https://accounts.google.com","OIDC_CLIENT_ID":"fune-test-client.apps.googleusercontent.com","OIDC_CLIENT_SECRET":"test-secret-oidc","OIDC_SCOPES":"email profile"},"args":["https://app.acme.example/auth/callback"],"expectError":"OIDC_SCOPES is \"email profile\"; it must include openid"},
  {"fn":"beginSignIn","name":"a callback over plain http on a real host is refused","provider":"github","env":{"SESSION_SECRET":"test-session-secret-0123456789abcdefghij","GITHUB_CLIENT_ID":"Iv1.fune0test0client","GITHUB_CLIENT_SECRET":"test-secret-github"},"args":["http://app.acme.example/callback"],"expectError":"redirectUri is your callback's full URL over https"},
  {"fn":"beginSignIn","name":"returnTo to another site is refused (open redirect)","provider":"github","env":{"SESSION_SECRET":"test-session-secret-0123456789abcdefghij","GITHUB_CLIENT_ID":"Iv1.fune0test0client","GITHUB_CLIENT_SECRET":"test-secret-github"},"args":["https://app.acme.example/auth/callback","//evil.example/steal"],"expectError":"returnTo is a path on this site"},
  {"fn":"beginSignIn","name":"no provider chosen","env":{"SESSION_SECRET":"test-session-secret-0123456789abcdefghij"},"args":["https://app.acme.example/auth/callback"],"expectError":"AUTH_PROVIDER is not set; set it to one of oidc, github"},
  {"fn":"beginSignIn","name":"a short SESSION_SECRET is refused","provider":"github","env":{"SESSION_SECRET":"too-short","GITHUB_CLIENT_ID":"Iv1.fune0test0client","GITHUB_CLIENT_SECRET":"test-secret-github"},"args":["https://app.acme.example/auth/callback"],"expectError":"SESSION_SECRET is 9 characters; it needs at least 32"},
  {"fn":"beginSignIn","name":"github: no client id","provider":"github","env":{"SESSION_SECRET":"test-session-secret-0123456789abcdefghij"},"args":["https://app.acme.example/auth/callback"],"expectError":"GITHUB_CLIENT_ID is not set"},
  {"fn":"completeSignIn","name":"oidc: Google, a confidential client: the code, the verifier and the id_token's claims","provider":"oidc","env":{"SESSION_SECRET":"test-session-secret-0123456789abcdefghij","OIDC_ISSUER":"https://accounts.google.com","OIDC_CLIENT_ID":"fune-test-client.apps.googleusercontent.com","OIDC_CLIENT_SECRET":"test-secret-oidc"},"args":["https://app.acme.example/auth/callback?state=c3RhdGUtZm9yLXRlc3Rz&code=4%2F0AfJohXtestcode&scope=email+profile+openid&authuser=0&prompt=consent","eyJ0Ijoic2lnbmluIiwicCI6Im9pZGMiLCJzdCI6ImMzUmhkR1V0Wm05eUxYUmxjM1J6IiwidiI6ImRtVnlhV1pwWlhJdFptOXlMV0V0ZEdWemRDMTBhR0YwTFdsekxXeHZibWN0Wlc1dmRXZG8iLCJuIjoiYm05dVkyVXRabTl5TFhSbGMzUnoiLCJ1IjoiaHR0cHM6Ly9hcHAuYWNtZS5leGFtcGxlL2F1dGgvY2FsbGJhY2siLCJyIjoiL2Rhc2hib2FyZCIsImV4cCI6MTc2NzIyNjIwMH0.TZyOOowXBLtnoZmCLHljrevno1mMzadptFR3i_EOeDA"],"exchanges":[{"request":{"method":"GET","url":"https://accounts.google.com/.well-known/openid-configuration","headers":{"accept":"application/json"}},"response":{"status":200,"json":{"issuer":"https://accounts.google.com","authorization_endpoint":"https://accounts.google.com/o/oauth2/v2/auth","device_authorization_endpoint":"https://oauth2.googleapis.com/device/code","token_endpoint":"https://oauth2.googleapis.com/token","userinfo_endpoint":"https://openidconnect.googleapis.com/v1/userinfo","revocation_endpoint":"https://oauth2.googleapis.com/revoke","jwks_uri":"https://www.googleapis.com/oauth2/v3/certs","response_types_supported":["code","token","id_token","code token","code id_token","token id_token","code token id_token","none"],"subject_types_supported":["public"],"id_token_signing_alg_values_supported":["RS256"],"scopes_supported":["openid","email","profile"],"token_endpoint_auth_methods_supported":["client_secret_post","client_secret_basic"],"claims_supported":["aud","email","email_verified","exp","family_name","given_name","iat","iss","name","picture","sub"],"code_challenge_methods_supported":["plain","S256"],"grant_types_supported":["authorization_code","refresh_token","urn:ietf:params:oauth:grant-type:device_code","urn:ietf:params:oauth:grant-type:jwt-bearer"]}}},{"request":{"method":"POST","url":"https://oauth2.googleapis.com/token","headers":{"content-type":"application/x-www-form-urlencoded","accept":"application/json"},"form":{"grant_type":"authorization_code","code":"4/0AfJohXtestcode","redirect_uri":"https://app.acme.example/auth/callback","client_id":"fune-test-client.apps.googleusercontent.com","code_verifier":"dmVyaWZpZXItZm9yLWEtdGVzdC10aGF0LWlzLWxvbmctZW5vdWdo","client_secret":"test-secret-oidc"}},"response":{"status":200,"json":{"access_token":"ya29.test-access-token","expires_in":3599,"scope":"openid https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile","token_type":"Bearer","id_token":"eyJhbGciOiJSUzI1NiIsImtpZCI6InRlc3Qta2V5IiwidHlwIjoiSldUIn0.eyJpc3MiOiJodHRwczovL2FjY291bnRzLmdvb2dsZS5jb20iLCJhenAiOiJmdW5lLXRlc3QtY2xpZW50LmFwcHMuZ29vZ2xldXNlcmNvbnRlbnQuY29tIiwiYXVkIjoiZnVuZS10ZXN0LWNsaWVudC5hcHBzLmdvb2dsZXVzZXJjb250ZW50LmNvbSIsInN1YiI6IjExMDE2OTQ4NDQ3NDM4NjI3NjMzNCIsImVtYWlsIjoiYWRhQGV4YW1wbGUuY29tIiwiZW1haWxfdmVyaWZpZWQiOnRydWUsImF0X2hhc2giOiJ0ZXN0Iiwibm9uY2UiOiJibTl1WTJVdFptOXlMWFJsYzNSeiIsIm5hbWUiOiJBZGEgTG92ZWxhY2UiLCJpYXQiOjE3NjcyMjU1OTUsImV4cCI6MTc2NzIyOTE5NX0.dGVzdC1zaWduYXR1cmU"}}}],"expect":{"provider":"oidc","subject":"110169484474386276334","email":"ada@example.com","emailVerified":true,"name":"Ada Lovelace","returnTo":"/dashboard"}},
  {"fn":"completeSignIn","name":"oidc: a public client, aud as a list, no email_verified or name","provider":"oidc","env":{"SESSION_SECRET":"test-session-secret-0123456789abcdefghij","OIDC_ISSUER":"https://id.acme.example/realms/acme/","OIDC_CLIENT_ID":"acme-web","OIDC_SCOPES":"openid email"},"args":["https://app.acme.example/auth/callback?session_state=abc&state=c3RhdGUtZm9yLXRlc3Rz&code=kc-code-1","eyJ0Ijoic2lnbmluIiwicCI6Im9pZGMiLCJzdCI6ImMzUmhkR1V0Wm05eUxYUmxjM1J6IiwidiI6ImRtVnlhV1pwWlhJdFptOXlMV0V0ZEdWemRDMTBhR0YwTFdsekxXeHZibWN0Wlc1dmRXZG8iLCJuIjoiYm05dVkyVXRabTl5TFhSbGMzUnoiLCJ1IjoiaHR0cHM6Ly9hcHAuYWNtZS5leGFtcGxlL2F1dGgvY2FsbGJhY2siLCJyIjpudWxsLCJleHAiOjE3NjcyMjYyMDB9.A7NHuR1H3FDVH2Ar1He5iC5GjwkPDQGszEFRAolEsUY"],"exchanges":[{"request":{"method":"GET","url":"https://id.acme.example/realms/acme/.well-known/openid-configuration","headers":{"accept":"application/json"}},"response":{"status":200,"json":{"issuer":"https://id.acme.example/realms/acme","authorization_endpoint":"https://id.acme.example/realms/acme/protocol/openid-connect/auth?kc_idp_hint=staff","token_endpoint":"https://id.acme.example/realms/acme/protocol/openid-connect/token","userinfo_endpoint":"https://id.acme.example/realms/acme/protocol/openid-connect/userinfo","jwks_uri":"https://id.acme.example/realms/acme/protocol/openid-connect/certs","code_challenge_methods_supported":["plain","S256"]}}},{"request":{"method":"POST","url":"https://id.acme.example/realms/acme/protocol/openid-connect/token","form":{"grant_type":"authorization_code","code":"kc-code-1","redirect_uri":"https://app.acme.example/auth/callback","client_id":"acme-web","code_verifier":"dmVyaWZpZXItZm9yLWEtdGVzdC10aGF0LWlzLWxvbmctZW5vdWdo"}},"response":{"status":200,"json":{"access_token":"kc.test.token","token_type":"Bearer","expires_in":300,"id_token":"eyJhbGciOiJSUzI1NiIsImtpZCI6InRlc3Qta2V5IiwidHlwIjoiSldUIn0.eyJpc3MiOiJodHRwczovL2lkLmFjbWUuZXhhbXBsZS9yZWFsbXMvYWNtZSIsImF1ZCI6WyJhY21lLXdlYiIsImFjY291bnQiXSwic3ViIjoiZjFiMmMzZDQtMDAwMC00MDAwLTgwMDAtMDAwMDAwMDAwMDAxIiwibm9uY2UiOiJibTl1WTJVdFptOXlMWFJsYzNSeiIsImV4cCI6MTc2NzIyNTkwMCwiZW1haWwiOiJncmFjZUBhY21lLmV4YW1wbGUifQ.dGVzdC1zaWduYXR1cmU"}}}],"expect":{"provider":"oidc","subject":"f1b2c3d4-0000-4000-8000-000000000001","email":"grace@acme.example","emailVerified":false,"name":null,"returnTo":null}},
  {"fn":"completeSignIn","name":"oidc: a used or expired code is thrown with the issuer's reason","provider":"oidc","env":{"SESSION_SECRET":"test-session-secret-0123456789abcdefghij","OIDC_ISSUER":"https://accounts.google.com","OIDC_CLIENT_ID":"fune-test-client.apps.googleusercontent.com","OIDC_CLIENT_SECRET":"test-secret-oidc"},"args":["https://app.acme.example/auth/callback?state=c3RhdGUtZm9yLXRlc3Rz&code=4%2F0AfJohXtestcode&scope=email+profile+openid&authuser=0&prompt=consent","eyJ0Ijoic2lnbmluIiwicCI6Im9pZGMiLCJzdCI6ImMzUmhkR1V0Wm05eUxYUmxjM1J6IiwidiI6ImRtVnlhV1pwWlhJdFptOXlMV0V0ZEdWemRDMTBhR0YwTFdsekxXeHZibWN0Wlc1dmRXZG8iLCJuIjoiYm05dVkyVXRabTl5TFhSbGMzUnoiLCJ1IjoiaHR0cHM6Ly9hcHAuYWNtZS5leGFtcGxlL2F1dGgvY2FsbGJhY2siLCJyIjoiL2Rhc2hib2FyZCIsImV4cCI6MTc2NzIyNjIwMH0.TZyOOowXBLtnoZmCLHljrevno1mMzadptFR3i_EOeDA"],"exchanges":[{"request":{"method":"GET","url":"https://accounts.google.com/.well-known/openid-configuration","headers":{"accept":"application/json"}},"response":{"status":200,"json":{"issuer":"https://accounts.google.com","authorization_endpoint":"https://accounts.google.com/o/oauth2/v2/auth","device_authorization_endpoint":"https://oauth2.googleapis.com/device/code","token_endpoint":"https://oauth2.googleapis.com/token","userinfo_endpoint":"https://openidconnect.googleapis.com/v1/userinfo","revocation_endpoint":"https://oauth2.googleapis.com/revoke","jwks_uri":"https://www.googleapis.com/oauth2/v3/certs","response_types_supported":["code","token","id_token","code token","code id_token","token id_token","code token id_token","none"],"subject_types_supported":["public"],"id_token_signing_alg_values_supported":["RS256"],"scopes_supported":["openid","email","profile"],"token_endpoint_auth_methods_supported":["client_secret_post","client_secret_basic"],"claims_supported":["aud","email","email_verified","exp","family_name","given_name","iat","iss","name","picture","sub"],"code_challenge_methods_supported":["plain","S256"],"grant_types_supported":["authorization_code","refresh_token","urn:ietf:params:oauth:grant-type:device_code","urn:ietf:params:oauth:grant-type:jwt-bearer"]}}},{"request":{"method":"POST","url":"https://oauth2.googleapis.com/token"},"response":{"status":400,"json":{"error":"invalid_grant","error_description":"Bad Request"}}}],"expectError":"oidc: the token endpoint refused the code (400 invalid_grant): Bad Request"},
  {"fn":"completeSignIn","name":"oidc: an id_token minted for another sign-in (nonce) is refused","provider":"oidc","env":{"SESSION_SECRET":"test-session-secret-0123456789abcdefghij","OIDC_ISSUER":"https://accounts.google.com","OIDC_CLIENT_ID":"fune-test-client.apps.googleusercontent.com","OIDC_CLIENT_SECRET":"test-secret-oidc"},"args":["https://app.acme.example/auth/callback?state=c3RhdGUtZm9yLXRlc3Rz&code=4%2F0AfJohXtestcode&scope=email+profile+openid&authuser=0&prompt=consent","eyJ0Ijoic2lnbmluIiwicCI6Im9pZGMiLCJzdCI6ImMzUmhkR1V0Wm05eUxYUmxjM1J6IiwidiI6ImRtVnlhV1pwWlhJdFptOXlMV0V0ZEdWemRDMTBhR0YwTFdsekxXeHZibWN0Wlc1dmRXZG8iLCJuIjoiYm05dVkyVXRabTl5TFhSbGMzUnoiLCJ1IjoiaHR0cHM6Ly9hcHAuYWNtZS5leGFtcGxlL2F1dGgvY2FsbGJhY2siLCJyIjoiL2Rhc2hib2FyZCIsImV4cCI6MTc2NzIyNjIwMH0.TZyOOowXBLtnoZmCLHljrevno1mMzadptFR3i_EOeDA"],"exchanges":[{"request":{"method":"GET","url":"https://accounts.google.com/.well-known/openid-configuration","headers":{"accept":"application/json"}},"response":{"status":200,"json":{"issuer":"https://accounts.google.com","authorization_endpoint":"https://accounts.google.com/o/oauth2/v2/auth","device_authorization_endpoint":"https://oauth2.googleapis.com/device/code","token_endpoint":"https://oauth2.googleapis.com/token","userinfo_endpoint":"https://openidconnect.googleapis.com/v1/userinfo","revocation_endpoint":"https://oauth2.googleapis.com/revoke","jwks_uri":"https://www.googleapis.com/oauth2/v3/certs","response_types_supported":["code","token","id_token","code token","code id_token","token id_token","code token id_token","none"],"subject_types_supported":["public"],"id_token_signing_alg_values_supported":["RS256"],"scopes_supported":["openid","email","profile"],"token_endpoint_auth_methods_supported":["client_secret_post","client_secret_basic"],"claims_supported":["aud","email","email_verified","exp","family_name","given_name","iat","iss","name","picture","sub"],"code_challenge_methods_supported":["plain","S256"],"grant_types_supported":["authorization_code","refresh_token","urn:ietf:params:oauth:grant-type:device_code","urn:ietf:params:oauth:grant-type:jwt-bearer"]}}},{"request":{"method":"POST","url":"https://oauth2.googleapis.com/token","headers":{"content-type":"application/x-www-form-urlencoded","accept":"application/json"},"form":{"grant_type":"authorization_code","code":"4/0AfJohXtestcode","redirect_uri":"https://app.acme.example/auth/callback","client_id":"fune-test-client.apps.googleusercontent.com","code_verifier":"dmVyaWZpZXItZm9yLWEtdGVzdC10aGF0LWlzLWxvbmctZW5vdWdo","client_secret":"test-secret-oidc"}},"response":{"status":200,"json":{"access_token":"ya29.test-access-token","expires_in":3599,"scope":"openid https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile","token_type":"Bearer","id_token":"eyJhbGciOiJSUzI1NiIsImtpZCI6InRlc3Qta2V5IiwidHlwIjoiSldUIn0.eyJpc3MiOiJodHRwczovL2FjY291bnRzLmdvb2dsZS5jb20iLCJhenAiOiJmdW5lLXRlc3QtY2xpZW50LmFwcHMuZ29vZ2xldXNlcmNvbnRlbnQuY29tIiwiYXVkIjoiZnVuZS10ZXN0LWNsaWVudC5hcHBzLmdvb2dsZXVzZXJjb250ZW50LmNvbSIsInN1YiI6IjExMDE2OTQ4NDQ3NDM4NjI3NjMzNCIsImVtYWlsIjoiYWRhQGV4YW1wbGUuY29tIiwiZW1haWxfdmVyaWZpZWQiOnRydWUsImF0X2hhc2giOiJ0ZXN0Iiwibm9uY2UiOiJzb21lLW90aGVyLW5vbmNlIiwibmFtZSI6IkFkYSBMb3ZlbGFjZSIsImlhdCI6MTc2NzIyNTU5NSwiZXhwIjoxNzY3MjI5MTk1fQ.dGVzdC1zaWduYXR1cmU"}}}],"expectError":"oidc: the id_token's nonce does not match this sign-in"},
  {"fn":"completeSignIn","name":"oidc: an expired id_token is refused","provider":"oidc","env":{"SESSION_SECRET":"test-session-secret-0123456789abcdefghij","OIDC_ISSUER":"https://accounts.google.com","OIDC_CLIENT_ID":"fune-test-client.apps.googleusercontent.com","OIDC_CLIENT_SECRET":"test-secret-oidc"},"args":["https://app.acme.example/auth/callback?state=c3RhdGUtZm9yLXRlc3Rz&code=4%2F0AfJohXtestcode&scope=email+profile+openid&authuser=0&prompt=consent","eyJ0Ijoic2lnbmluIiwicCI6Im9pZGMiLCJzdCI6ImMzUmhkR1V0Wm05eUxYUmxjM1J6IiwidiI6ImRtVnlhV1pwWlhJdFptOXlMV0V0ZEdWemRDMTBhR0YwTFdsekxXeHZibWN0Wlc1dmRXZG8iLCJuIjoiYm05dVkyVXRabTl5TFhSbGMzUnoiLCJ1IjoiaHR0cHM6Ly9hcHAuYWNtZS5leGFtcGxlL2F1dGgvY2FsbGJhY2siLCJyIjoiL2Rhc2hib2FyZCIsImV4cCI6MTc2NzIyNjIwMH0.TZyOOowXBLtnoZmCLHljrevno1mMzadptFR3i_EOeDA"],"exchanges":[{"request":{"method":"GET","url":"https://accounts.google.com/.well-known/openid-configuration","headers":{"accept":"application/json"}},"response":{"status":200,"json":{"issuer":"https://accounts.google.com","authorization_endpoint":"https://accounts.google.com/o/oauth2/v2/auth","device_authorization_endpoint":"https://oauth2.googleapis.com/device/code","token_endpoint":"https://oauth2.googleapis.com/token","userinfo_endpoint":"https://openidconnect.googleapis.com/v1/userinfo","revocation_endpoint":"https://oauth2.googleapis.com/revoke","jwks_uri":"https://www.googleapis.com/oauth2/v3/certs","response_types_supported":["code","token","id_token","code token","code id_token","token id_token","code token id_token","none"],"subject_types_supported":["public"],"id_token_signing_alg_values_supported":["RS256"],"scopes_supported":["openid","email","profile"],"token_endpoint_auth_methods_supported":["client_secret_post","client_secret_basic"],"claims_supported":["aud","email","email_verified","exp","family_name","given_name","iat","iss","name","picture","sub"],"code_challenge_methods_supported":["plain","S256"],"grant_types_supported":["authorization_code","refresh_token","urn:ietf:params:oauth:grant-type:device_code","urn:ietf:params:oauth:grant-type:jwt-bearer"]}}},{"request":{"method":"POST","url":"https://oauth2.googleapis.com/token","headers":{"content-type":"application/x-www-form-urlencoded","accept":"application/json"},"form":{"grant_type":"authorization_code","code":"4/0AfJohXtestcode","redirect_uri":"https://app.acme.example/auth/callback","client_id":"fune-test-client.apps.googleusercontent.com","code_verifier":"dmVyaWZpZXItZm9yLWEtdGVzdC10aGF0LWlzLWxvbmctZW5vdWdo","client_secret":"test-secret-oidc"}},"response":{"status":200,"json":{"access_token":"ya29.test-access-token","expires_in":3599,"scope":"openid https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile","token_type":"Bearer","id_token":"eyJhbGciOiJSUzI1NiIsImtpZCI6InRlc3Qta2V5IiwidHlwIjoiSldUIn0.eyJpc3MiOiJodHRwczovL2FjY291bnRzLmdvb2dsZS5jb20iLCJhenAiOiJmdW5lLXRlc3QtY2xpZW50LmFwcHMuZ29vZ2xldXNlcmNvbnRlbnQuY29tIiwiYXVkIjoiZnVuZS10ZXN0LWNsaWVudC5hcHBzLmdvb2dsZXVzZXJjb250ZW50LmNvbSIsInN1YiI6IjExMDE2OTQ4NDQ3NDM4NjI3NjMzNCIsImVtYWlsIjoiYWRhQGV4YW1wbGUuY29tIiwiZW1haWxfdmVyaWZpZWQiOnRydWUsImF0X2hhc2giOiJ0ZXN0Iiwibm9uY2UiOiJibTl1WTJVdFptOXlMWFJsYzNSeiIsIm5hbWUiOiJBZGEgTG92ZWxhY2UiLCJpYXQiOjE3NjcyMjU1OTUsImV4cCI6MTc2NzIyNTU5OX0.dGVzdC1zaWduYXR1cmU"}}}],"expectError":"oidc: the id_token has expired"},
  {"fn":"completeSignIn","name":"oidc: an id_token for another client is refused","provider":"oidc","env":{"SESSION_SECRET":"test-session-secret-0123456789abcdefghij","OIDC_ISSUER":"https://accounts.google.com","OIDC_CLIENT_ID":"fune-test-client.apps.googleusercontent.com","OIDC_CLIENT_SECRET":"test-secret-oidc"},"args":["https://app.acme.example/auth/callback?state=c3RhdGUtZm9yLXRlc3Rz&code=4%2F0AfJohXtestcode&scope=email+profile+openid&authuser=0&prompt=consent","eyJ0Ijoic2lnbmluIiwicCI6Im9pZGMiLCJzdCI6ImMzUmhkR1V0Wm05eUxYUmxjM1J6IiwidiI6ImRtVnlhV1pwWlhJdFptOXlMV0V0ZEdWemRDMTBhR0YwTFdsekxXeHZibWN0Wlc1dmRXZG8iLCJuIjoiYm05dVkyVXRabTl5TFhSbGMzUnoiLCJ1IjoiaHR0cHM6Ly9hcHAuYWNtZS5leGFtcGxlL2F1dGgvY2FsbGJhY2siLCJyIjoiL2Rhc2hib2FyZCIsImV4cCI6MTc2NzIyNjIwMH0.TZyOOowXBLtnoZmCLHljrevno1mMzadptFR3i_EOeDA"],"exchanges":[{"request":{"method":"GET","url":"https://accounts.google.com/.well-known/openid-configuration","headers":{"accept":"application/json"}},"response":{"status":200,"json":{"issuer":"https://accounts.google.com","authorization_endpoint":"https://accounts.google.com/o/oauth2/v2/auth","device_authorization_endpoint":"https://oauth2.googleapis.com/device/code","token_endpoint":"https://oauth2.googleapis.com/token","userinfo_endpoint":"https://openidconnect.googleapis.com/v1/userinfo","revocation_endpoint":"https://oauth2.googleapis.com/revoke","jwks_uri":"https://www.googleapis.com/oauth2/v3/certs","response_types_supported":["code","token","id_token","code token","code id_token","token id_token","code token id_token","none"],"subject_types_supported":["public"],"id_token_signing_alg_values_supported":["RS256"],"scopes_supported":["openid","email","profile"],"token_endpoint_auth_methods_supported":["client_secret_post","client_secret_basic"],"claims_supported":["aud","email","email_verified","exp","family_name","given_name","iat","iss","name","picture","sub"],"code_challenge_methods_supported":["plain","S256"],"grant_types_supported":["authorization_code","refresh_token","urn:ietf:params:oauth:grant-type:device_code","urn:ietf:params:oauth:grant-type:jwt-bearer"]}}},{"request":{"method":"POST","url":"https://oauth2.googleapis.com/token","headers":{"content-type":"application/x-www-form-urlencoded","accept":"application/json"},"form":{"grant_type":"authorization_code","code":"4/0AfJohXtestcode","redirect_uri":"https://app.acme.example/auth/callback","client_id":"fune-test-client.apps.googleusercontent.com","code_verifier":"dmVyaWZpZXItZm9yLWEtdGVzdC10aGF0LWlzLWxvbmctZW5vdWdo","client_secret":"test-secret-oidc"}},"response":{"status":200,"json":{"access_token":"ya29.test-access-token","expires_in":3599,"scope":"openid https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile","token_type":"Bearer","id_token":"eyJhbGciOiJSUzI1NiIsImtpZCI6InRlc3Qta2V5IiwidHlwIjoiSldUIn0.eyJpc3MiOiJodHRwczovL2FjY291bnRzLmdvb2dsZS5jb20iLCJhenAiOiJmdW5lLXRlc3QtY2xpZW50LmFwcHMuZ29vZ2xldXNlcmNvbnRlbnQuY29tIiwiYXVkIjoic29tZW9uZS1lbHNlLmFwcHMuZ29vZ2xldXNlcmNvbnRlbnQuY29tIiwic3ViIjoiMTEwMTY5NDg0NDc0Mzg2Mjc2MzM0IiwiZW1haWwiOiJhZGFAZXhhbXBsZS5jb20iLCJlbWFpbF92ZXJpZmllZCI6dHJ1ZSwiYXRfaGFzaCI6InRlc3QiLCJub25jZSI6ImJtOXVZMlV0Wm05eUxYUmxjM1J6IiwibmFtZSI6IkFkYSBMb3ZlbGFjZSIsImlhdCI6MTc2NzIyNTU5NSwiZXhwIjoxNzY3MjI5MTk1fQ.dGVzdC1zaWduYXR1cmU"}}}],"expectError":"oidc: the id_token is not for OIDC_CLIENT_ID (aud)"},
  {"fn":"completeSignIn","name":"github: the token, the user and their primary verified email","provider":"github","env":{"SESSION_SECRET":"test-session-secret-0123456789abcdefghij","GITHUB_CLIENT_ID":"Iv1.fune0test0client","GITHUB_CLIENT_SECRET":"test-secret-github"},"args":["https://app.acme.example/auth/callback?code=ghcode123&state=c3RhdGUtZm9yLXRlc3Rz","eyJ0Ijoic2lnbmluIiwicCI6ImdpdGh1YiIsInN0IjoiYzNSaGRHVXRabTl5TFhSbGMzUnoiLCJ2IjoiZG1WeWFXWnBaWEl0Wm05eUxXRXRkR1Z6ZEMxMGFHRjBMV2x6TFd4dmJtY3RaVzV2ZFdkbyIsIm4iOiJibTl1WTJVdFptOXlMWFJsYzNSeiIsInUiOiJodHRwczovL2FwcC5hY21lLmV4YW1wbGUvYXV0aC9jYWxsYmFjayIsInIiOiIvc2V0dGluZ3MiLCJleHAiOjE3NjcyMjYyMDB9.T5zft2iauR1IRCzTAWnMDxSnLtkuysOpFhz-NNh-FkM"],"exchanges":[{"request":{"method":"POST","url":"https://github.com/login/oauth/access_token","headers":{"accept":"application/json"},"form":{"client_id":"Iv1.fune0test0client","client_secret":"test-secret-github","code":"ghcode123","redirect_uri":"https://app.acme.example/auth/callback","code_verifier":"dmVyaWZpZXItZm9yLWEtdGVzdC10aGF0LWlzLWxvbmctZW5vdWdo"}},"response":{"status":200,"json":{"access_token":"gho_test_token","token_type":"bearer","scope":"read:user,user:email"}}},{"request":{"method":"GET","url":"https://api.github.com/user","headers":{"authorization":"Bearer gho_test_token","accept":"application/vnd.github+json","user-agent":"fune-auth-oauth-sign-in"}},"response":{"status":200,"json":{"login":"octocat","id":583231,"node_id":"MDQ6VXNlcjU4MzIzMQ==","type":"User","name":"The Octocat","company":"@github","email":null}}},{"request":{"method":"GET","url":"https://api.github.com/user/emails","headers":{"authorization":"Bearer gho_test_token","accept":"application/vnd.github+json","user-agent":"fune-auth-oauth-sign-in"}},"response":{"status":200,"json":[{"email":"octocat@users.noreply.github.com","primary":false,"verified":true,"visibility":null},{"email":"octocat@github.com","primary":true,"verified":true,"visibility":"public"}]}}],"expect":{"provider":"github","subject":"583231","email":"octocat@github.com","emailVerified":true,"name":"The Octocat","returnTo":"/settings"}},
  {"fn":"completeSignIn","name":"github: no verified email, and no name but the login","provider":"github","env":{"SESSION_SECRET":"test-session-secret-0123456789abcdefghij","GITHUB_CLIENT_ID":"Iv1.fune0test0client","GITHUB_CLIENT_SECRET":"test-secret-github"},"args":["https://app.acme.example/auth/callback?code=ghcode123&state=c3RhdGUtZm9yLXRlc3Rz","eyJ0Ijoic2lnbmluIiwicCI6ImdpdGh1YiIsInN0IjoiYzNSaGRHVXRabTl5TFhSbGMzUnoiLCJ2IjoiZG1WeWFXWnBaWEl0Wm05eUxXRXRkR1Z6ZEMxMGFHRjBMV2x6TFd4dmJtY3RaVzV2ZFdkbyIsIm4iOiJibTl1WTJVdFptOXlMWFJsYzNSeiIsInUiOiJodHRwczovL2FwcC5hY21lLmV4YW1wbGUvYXV0aC9jYWxsYmFjayIsInIiOiIvZGFzaGJvYXJkIiwiZXhwIjoxNzY3MjI2MjAwfQ.EEmzhCMpCga9VzjwPKviybk8ffchSqv3l3lAgG-B_Wg"],"exchanges":[{"request":{"method":"POST","url":"https://github.com/login/oauth/access_token","headers":{"accept":"application/json"},"form":{"client_id":"Iv1.fune0test0client","client_secret":"test-secret-github","code":"ghcode123","redirect_uri":"https://app.acme.example/auth/callback","code_verifier":"dmVyaWZpZXItZm9yLWEtdGVzdC10aGF0LWlzLWxvbmctZW5vdWdo"}},"response":{"status":200,"json":{"access_token":"gho_test_token","token_type":"bearer","scope":"read:user,user:email"}}},{"request":{"method":"GET","url":"https://api.github.com/user","headers":{"authorization":"Bearer gho_test_token","accept":"application/vnd.github+json","user-agent":"fune-auth-oauth-sign-in"}},"response":{"status":200,"json":{"login":"octocat","id":583231,"node_id":"MDQ6VXNlcjU4MzIzMQ==","type":"User","name":null,"company":"@github","email":null}}},{"request":{"method":"GET","url":"https://api.github.com/user/emails","headers":{"authorization":"Bearer gho_test_token","accept":"application/vnd.github+json","user-agent":"fune-auth-oauth-sign-in"}},"response":{"status":200,"json":[{"email":"octocat@github.com","primary":true,"verified":false,"visibility":"public"}]}}],"expect":{"provider":"github","subject":"583231","email":null,"emailVerified":false,"name":"octocat","returnTo":"/dashboard"}},
  {"fn":"completeSignIn","name":"github: a bad code comes back as status 200 with an error","provider":"github","env":{"SESSION_SECRET":"test-session-secret-0123456789abcdefghij","GITHUB_CLIENT_ID":"Iv1.fune0test0client","GITHUB_CLIENT_SECRET":"test-secret-github"},"args":["https://app.acme.example/auth/callback?code=ghcode123&state=c3RhdGUtZm9yLXRlc3Rz","eyJ0Ijoic2lnbmluIiwicCI6ImdpdGh1YiIsInN0IjoiYzNSaGRHVXRabTl5TFhSbGMzUnoiLCJ2IjoiZG1WeWFXWnBaWEl0Wm05eUxXRXRkR1Z6ZEMxMGFHRjBMV2x6TFd4dmJtY3RaVzV2ZFdkbyIsIm4iOiJibTl1WTJVdFptOXlMWFJsYzNSeiIsInUiOiJodHRwczovL2FwcC5hY21lLmV4YW1wbGUvYXV0aC9jYWxsYmFjayIsInIiOiIvZGFzaGJvYXJkIiwiZXhwIjoxNzY3MjI2MjAwfQ.EEmzhCMpCga9VzjwPKviybk8ffchSqv3l3lAgG-B_Wg"],"exchanges":[{"request":{"method":"POST","url":"https://github.com/login/oauth/access_token","headers":{"accept":"application/json"},"form":{"client_id":"Iv1.fune0test0client","client_secret":"test-secret-github","code":"ghcode123","redirect_uri":"https://app.acme.example/auth/callback","code_verifier":"dmVyaWZpZXItZm9yLWEtdGVzdC10aGF0LWlzLWxvbmctZW5vdWdo"}},"response":{"status":200,"json":{"error":"bad_verification_code","error_description":"The code passed is incorrect or expired.","error_uri":"https://docs.github.com/apps/managing-oauth-apps/troubleshooting-oauth-app-access-token-request-errors/#bad-verification-code"}}}],"expectError":"github: the token endpoint refused the code (200 bad_verification_code): The code passed is incorrect or expired."},
  {"fn":"completeSignIn","name":"the user declined","provider":"github","env":{"SESSION_SECRET":"test-session-secret-0123456789abcdefghij","GITHUB_CLIENT_ID":"Iv1.fune0test0client","GITHUB_CLIENT_SECRET":"test-secret-github"},"args":["https://app.acme.example/auth/callback?error=access_denied&error_description=The+user+has+denied+your+application+access.&state=c3RhdGUtZm9yLXRlc3Rz","eyJ0Ijoic2lnbmluIiwicCI6ImdpdGh1YiIsInN0IjoiYzNSaGRHVXRabTl5TFhSbGMzUnoiLCJ2IjoiZG1WeWFXWnBaWEl0Wm05eUxXRXRkR1Z6ZEMxMGFHRjBMV2x6TFd4dmJtY3RaVzV2ZFdkbyIsIm4iOiJibTl1WTJVdFptOXlMWFJsYzNSeiIsInUiOiJodHRwczovL2FwcC5hY21lLmV4YW1wbGUvYXV0aC9jYWxsYmFjayIsInIiOiIvZGFzaGJvYXJkIiwiZXhwIjoxNzY3MjI2MjAwfQ.EEmzhCMpCga9VzjwPKviybk8ffchSqv3l3lAgG-B_Wg"],"expectError":"the user declined to sign in (access_denied)"},
  {"fn":"completeSignIn","name":"a callback whose state is not the cookie's is refused before any request","provider":"oidc","env":{"SESSION_SECRET":"test-session-secret-0123456789abcdefghij","OIDC_ISSUER":"https://accounts.google.com","OIDC_CLIENT_ID":"fune-test-client.apps.googleusercontent.com","OIDC_CLIENT_SECRET":"test-secret-oidc"},"args":["https://app.acme.example/auth/callback?state=forged&code=x","eyJ0Ijoic2lnbmluIiwicCI6Im9pZGMiLCJzdCI6ImMzUmhkR1V0Wm05eUxYUmxjM1J6IiwidiI6ImRtVnlhV1pwWlhJdFptOXlMV0V0ZEdWemRDMTBhR0YwTFdsekxXeHZibWN0Wlc1dmRXZG8iLCJuIjoiYm05dVkyVXRabTl5TFhSbGMzUnoiLCJ1IjoiaHR0cHM6Ly9hcHAuYWNtZS5leGFtcGxlL2F1dGgvY2FsbGJhY2siLCJyIjoiL2Rhc2hib2FyZCIsImV4cCI6MTc2NzIyNjIwMH0.TZyOOowXBLtnoZmCLHljrevno1mMzadptFR3i_EOeDA"],"expectError":"the state in the callback does not match the sign-in cookie"},
  {"fn":"completeSignIn","name":"a sign-in cookie older than ten minutes","provider":"github","env":{"SESSION_SECRET":"test-session-secret-0123456789abcdefghij","GITHUB_CLIENT_ID":"Iv1.fune0test0client","GITHUB_CLIENT_SECRET":"test-secret-github"},"now":"2026-01-01T00:10:01Z","args":["https://app.acme.example/auth/callback?code=ghcode123&state=c3RhdGUtZm9yLXRlc3Rz","eyJ0Ijoic2lnbmluIiwicCI6ImdpdGh1YiIsInN0IjoiYzNSaGRHVXRabTl5TFhSbGMzUnoiLCJ2IjoiZG1WeWFXWnBaWEl0Wm05eUxXRXRkR1Z6ZEMxMGFHRjBMV2x6TFd4dmJtY3RaVzV2ZFdkbyIsIm4iOiJibTl1WTJVdFptOXlMWFJsYzNSeiIsInUiOiJodHRwczovL2FwcC5hY21lLmV4YW1wbGUvYXV0aC9jYWxsYmFjayIsInIiOiIvZGFzaGJvYXJkIiwiZXhwIjoxNzY3MjI2MjAwfQ.EEmzhCMpCga9VzjwPKviybk8ffchSqv3l3lAgG-B_Wg"],"expectError":"the sign-in cookie is missing, expired or not signed by SESSION_SECRET"},
  {"fn":"completeSignIn","name":"a sign-in cookie signed with another secret","provider":"oidc","env":{"SESSION_SECRET":"test-session-secret-0123456789abcdefghij","OIDC_ISSUER":"https://accounts.google.com","OIDC_CLIENT_ID":"fune-test-client.apps.googleusercontent.com","OIDC_CLIENT_SECRET":"test-secret-oidc"},"args":["https://app.acme.example/auth/callback?state=c3RhdGUtZm9yLXRlc3Rz&code=4%2F0AfJohXtestcode&scope=email+profile+openid&authuser=0&prompt=consent","eyJ0Ijoic2lnbmluIiwicCI6Im9pZGMiLCJzdCI6ImMzUmhkR1V0Wm05eUxYUmxjM1J6IiwidiI6ImRtVnlhV1pwWlhJdFptOXlMV0V0ZEdWemRDMTBhR0YwTFdsekxXeHZibWN0Wlc1dmRXZG8iLCJuIjoiYm05dVkyVXRabTl5TFhSbGMzUnoiLCJ1IjoiaHR0cHM6Ly9hcHAuYWNtZS5leGFtcGxlL2F1dGgvY2FsbGJhY2siLCJyIjoiL2Rhc2hib2FyZCIsImV4cCI6MTc2NzIyNjIwMH0.rLICS4pWbTY6X0TJe23p6s3gLHiJ7imCC3R_iJtpxUQ"],"expectError":"the sign-in cookie is missing, expired or not signed by SESSION_SECRET"},
  {"fn":"completeSignIn","name":"a session cookie is not a sign-in cookie","provider":"oidc","env":{"SESSION_SECRET":"test-session-secret-0123456789abcdefghij","OIDC_ISSUER":"https://accounts.google.com","OIDC_CLIENT_ID":"fune-test-client.apps.googleusercontent.com","OIDC_CLIENT_SECRET":"test-secret-oidc"},"args":["https://app.acme.example/auth/callback?state=c3RhdGUtZm9yLXRlc3Rz&code=4%2F0AfJohXtestcode&scope=email+profile+openid&authuser=0&prompt=consent","eyJ0Ijoic2Vzc2lvbiIsInAiOiJvaWRjIiwicyI6IjExMDE2OTQ4NDQ3NDM4NjI3NjMzNCIsImUiOiJhZGFAZXhhbXBsZS5jb20iLCJuIjoiQWRhIExvdmVsYWNlIiwiaWF0IjoxNzY3MjI1NjAwLCJleHAiOjE3Njk4MTc2MDB9.qvfebzx5jhjLQTrp6bf69WQQGV8dXD6g_Z9yHGuYXig"],"expectError":"the sign-in cookie is missing, expired or not signed by SESSION_SECRET"},
  {"fn":"completeSignIn","name":"a sign-in begun with another provider","provider":"oidc","env":{"SESSION_SECRET":"test-session-secret-0123456789abcdefghij","OIDC_ISSUER":"https://accounts.google.com","OIDC_CLIENT_ID":"fune-test-client.apps.googleusercontent.com","OIDC_CLIENT_SECRET":"test-secret-oidc"},"args":["https://app.acme.example/auth/callback?state=c3RhdGUtZm9yLXRlc3Rz&code=4%2F0AfJohXtestcode&scope=email+profile+openid&authuser=0&prompt=consent","eyJ0Ijoic2lnbmluIiwicCI6ImdpdGh1YiIsInN0IjoiYzNSaGRHVXRabTl5TFhSbGMzUnoiLCJ2IjoiZG1WeWFXWnBaWEl0Wm05eUxXRXRkR1Z6ZEMxMGFHRjBMV2x6TFd4dmJtY3RaVzV2ZFdkbyIsIm4iOiJibTl1WTJVdFptOXlMWFJsYzNSeiIsInUiOiJodHRwczovL2FwcC5hY21lLmV4YW1wbGUvYXV0aC9jYWxsYmFjayIsInIiOiIvZGFzaGJvYXJkIiwiZXhwIjoxNzY3MjI2MjAwfQ.EEmzhCMpCga9VzjwPKviybk8ffchSqv3l3lAgG-B_Wg"],"expectError":"this sign-in began with github, but AUTH_PROVIDER is oidc"},
  {"fn":"createSession","name":"a 30-day session by default","env":{"SESSION_SECRET":"test-session-secret-0123456789abcdefghij"},"args":[{"provider":"oidc","subject":"110169484474386276334","email":"ada@example.com","name":"Ada Lovelace"}],"expect":"eyJ0Ijoic2Vzc2lvbiIsInAiOiJvaWRjIiwicyI6IjExMDE2OTQ4NDQ3NDM4NjI3NjMzNCIsImUiOiJhZGFAZXhhbXBsZS5jb20iLCJuIjoiQWRhIExvdmVsYWNlIiwiaWF0IjoxNzY3MjI1NjAwLCJleHAiOjE3Njk4MTc2MDB9.qvfebzx5jhjLQTrp6bf69WQQGV8dXD6g_Z9yHGuYXig"},
  {"fn":"createSession","name":"an hour","env":{"SESSION_SECRET":"test-session-secret-0123456789abcdefghij"},"args":[{"provider":"github","subject":"583231","email":null,"name":"The Octocat"},3600],"expect":"eyJ0Ijoic2Vzc2lvbiIsInAiOiJnaXRodWIiLCJzIjoiNTgzMjMxIiwiZSI6bnVsbCwibiI6IlRoZSBPY3RvY2F0IiwiaWF0IjoxNzY3MjI1NjAwLCJleHAiOjE3NjcyMjkyMDB9.KAKaMhIhDK4HNrIqoK4ep77xBJnxhBTXIVHg3Lxpiqk"},
  {"fn":"createSession","name":"no email or name","env":{"SESSION_SECRET":"test-session-secret-0123456789abcdefghij"},"args":[{"provider":"github","subject":"1","email":null,"name":null},60],"expect":"eyJ0Ijoic2Vzc2lvbiIsInAiOiJnaXRodWIiLCJzIjoiMSIsImUiOm51bGwsIm4iOm51bGwsImlhdCI6MTc2NzIyNTYwMCwiZXhwIjoxNzY3MjI1NjYwfQ.VWB1PBfNPy0h4BysG59jAbCZepEOy6p9fTVKQscW2FE"},
  {"fn":"createSession","name":"issued at the clock's time","env":{"SESSION_SECRET":"test-session-secret-0123456789abcdefghij"},"now":"2026-06-30T23:59:59Z","args":[{"provider":"oidc","subject":"110169484474386276334","email":"ada@example.com","name":"Ada Lovelace"},86400],"expect":"eyJ0Ijoic2Vzc2lvbiIsInAiOiJvaWRjIiwicyI6IjExMDE2OTQ4NDQ3NDM4NjI3NjMzNCIsImUiOiJhZGFAZXhhbXBsZS5jb20iLCJuIjoiQWRhIExvdmVsYWNlIiwiaWF0IjoxNzgyODYzOTk5LCJleHAiOjE3ODI5NTAzOTl9.aU7PoQw1qaQMm00jYZebGYoUJv7MbgnBVc5N6M1AHJ8"},
  {"fn":"createSession","name":"a different secret signs differently","env":{"SESSION_SECRET":"another-test-secret-0123456789abcdefghij"},"args":[{"provider":"oidc","subject":"110169484474386276334","email":"ada@example.com","name":"Ada Lovelace"}],"expect":"eyJ0Ijoic2Vzc2lvbiIsInAiOiJvaWRjIiwicyI6IjExMDE2OTQ4NDQ3NDM4NjI3NjMzNCIsImUiOiJhZGFAZXhhbXBsZS5jb20iLCJuIjoiQWRhIExvdmVsYWNlIiwiaWF0IjoxNzY3MjI1NjAwLCJleHAiOjE3Njk4MTc2MDB9.zP8b0qxATMXfo_3kletJemfc6PmtR-BQJTXwZNLjn8k"},
  {"fn":"createSession","name":"no lifetime","env":{"SESSION_SECRET":"test-session-secret-0123456789abcdefghij"},"args":[{"provider":"oidc","subject":"110169484474386276334","email":"ada@example.com","name":"Ada Lovelace"},0],"expectError":"maxAgeSeconds is a whole number of seconds above 0, not 0"},
  {"fn":"createSession","name":"a fractional lifetime","env":{"SESSION_SECRET":"test-session-secret-0123456789abcdefghij"},"args":[{"provider":"oidc","subject":"110169484474386276334","email":"ada@example.com","name":"Ada Lovelace"},1.5],"expectError":"maxAgeSeconds is a whole number of seconds above 0, not 1.5"},
  {"fn":"createSession","name":"no subject","env":{"SESSION_SECRET":"test-session-secret-0123456789abcdefghij"},"args":[{"provider":"oidc","subject":"","email":null,"name":null}],"expectError":"a session needs the user's subject"},
  {"fn":"createSession","name":"no secret","args":[{"provider":"oidc","subject":"110169484474386276334","email":"ada@example.com","name":"Ada Lovelace"}],"expectError":"SESSION_SECRET is not set"},
  {"fn":"createSession","name":"a short secret","env":{"SESSION_SECRET":"0123456789012345678901234567890"},"args":[{"provider":"oidc","subject":"110169484474386276334","email":"ada@example.com","name":"Ada Lovelace"}],"expectError":"SESSION_SECRET is 31 characters; it needs at least 32"},
  {"fn":"readSession","name":"a valid session","env":{"SESSION_SECRET":"test-session-secret-0123456789abcdefghij"},"args":["eyJ0Ijoic2Vzc2lvbiIsInAiOiJvaWRjIiwicyI6IjExMDE2OTQ4NDQ3NDM4NjI3NjMzNCIsImUiOiJhZGFAZXhhbXBsZS5jb20iLCJuIjoiQWRhIExvdmVsYWNlIiwiaWF0IjoxNzY3MjI1NjAwLCJleHAiOjE3Njk4MTc2MDB9.qvfebzx5jhjLQTrp6bf69WQQGV8dXD6g_Z9yHGuYXig"],"expect":{"provider":"oidc","subject":"110169484474386276334","email":"ada@example.com","name":"Ada Lovelace"}},
  {"fn":"readSession","name":"a session one second before it expires","env":{"SESSION_SECRET":"test-session-secret-0123456789abcdefghij"},"now":"2026-01-01T00:59:59Z","args":["eyJ0Ijoic2Vzc2lvbiIsInAiOiJnaXRodWIiLCJzIjoiNTgzMjMxIiwiZSI6bnVsbCwibiI6IlRoZSBPY3RvY2F0IiwiaWF0IjoxNzY3MjI1NjAwLCJleHAiOjE3NjcyMjkyMDB9.KAKaMhIhDK4HNrIqoK4ep77xBJnxhBTXIVHg3Lxpiqk"],"expect":{"provider":"github","subject":"583231","email":null,"name":"The Octocat"}},
  {"fn":"readSession","name":"an expired session","env":{"SESSION_SECRET":"test-session-secret-0123456789abcdefghij"},"now":"2026-01-01T01:00:00Z","args":["eyJ0Ijoic2Vzc2lvbiIsInAiOiJnaXRodWIiLCJzIjoiNTgzMjMxIiwiZSI6bnVsbCwibiI6IlRoZSBPY3RvY2F0IiwiaWF0IjoxNzY3MjI1NjAwLCJleHAiOjE3NjcyMjkyMDB9.KAKaMhIhDK4HNrIqoK4ep77xBJnxhBTXIVHg3Lxpiqk"],"expect":null},
  {"fn":"readSession","name":"no cookie","env":{"SESSION_SECRET":"test-session-secret-0123456789abcdefghij"},"args":[null],"expect":null},
  {"fn":"readSession","name":"an empty cookie","env":{"SESSION_SECRET":"test-session-secret-0123456789abcdefghij"},"args":[""],"expect":null},
  {"fn":"readSession","name":"an edited payload (someone made themselves another user)","env":{"SESSION_SECRET":"test-session-secret-0123456789abcdefghij"},"args":["eyJ0Ijoic2Vzc2lvbiIsInAiOiJvaWRjIiwicyI6ImFkbWluIiwiZSI6bnVsbCwibiI6bnVsbCwiaWF0IjoxNzY3MjI1NjAwLCJleHAiOjE3NjcyMjU2NjB9.qvfebzx5jhjLQTrp6bf69WQQGV8dXD6g_Z9yHGuYXig"],"expect":null},
  {"fn":"readSession","name":"signed with another secret","env":{"SESSION_SECRET":"test-session-secret-0123456789abcdefghij"},"args":["eyJ0Ijoic2Vzc2lvbiIsInAiOiJvaWRjIiwicyI6IjExMDE2OTQ4NDQ3NDM4NjI3NjMzNCIsImUiOiJhZGFAZXhhbXBsZS5jb20iLCJuIjoiQWRhIExvdmVsYWNlIiwiaWF0IjoxNzY3MjI1NjAwLCJleHAiOjE3Njk4MTc2MDB9.zP8b0qxATMXfo_3kletJemfc6PmtR-BQJTXwZNLjn8k"],"expect":null},
  {"fn":"readSession","name":"a sign-in cookie is not a session","env":{"SESSION_SECRET":"test-session-secret-0123456789abcdefghij"},"args":["eyJ0Ijoic2lnbmluIiwicCI6Im9pZGMiLCJzdCI6ImMzUmhkR1V0Wm05eUxYUmxjM1J6IiwidiI6ImRtVnlhV1pwWlhJdFptOXlMV0V0ZEdWemRDMTBhR0YwTFdsekxXeHZibWN0Wlc1dmRXZG8iLCJuIjoiYm05dVkyVXRabTl5TFhSbGMzUnoiLCJ1IjoiaHR0cHM6Ly9hcHAuYWNtZS5leGFtcGxlL2F1dGgvY2FsbGJhY2siLCJyIjoiL2Rhc2hib2FyZCIsImV4cCI6MTc2NzIyNjIwMH0.TZyOOowXBLtnoZmCLHljrevno1mMzadptFR3i_EOeDA"],"expect":null},
  {"fn":"readSession","name":"not a sealed value at all","env":{"SESSION_SECRET":"test-session-secret-0123456789abcdefghij"},"args":["hello; world"],"expect":null},
  {"fn":"readSession","name":"no secret is an error, not a signed-out user","args":["eyJ0Ijoic2Vzc2lvbiIsInAiOiJvaWRjIiwicyI6IjExMDE2OTQ4NDQ3NDM4NjI3NjMzNCIsImUiOiJhZGFAZXhhbXBsZS5jb20iLCJuIjoiQWRhIExvdmVsYWNlIiwiaWF0IjoxNzY3MjI1NjAwLCJleHAiOjE3Njk4MTc2MDB9.qvfebzx5jhjLQTrp6bf69WQQGV8dXD6g_Z9yHGuYXig"],"expectError":"SESSION_SECRET is not set"},
  {"fn":"sessionCookie","name":"a 30-day cookie by default","args":["eyJ0Ijoic2Vzc2lvbiIsInAiOiJvaWRjIiwicyI6IjExMDE2OTQ4NDQ3NDM4NjI3NjMzNCIsImUiOiJhZGFAZXhhbXBsZS5jb20iLCJuIjoiQWRhIExvdmVsYWNlIiwiaWF0IjoxNzY3MjI1NjAwLCJleHAiOjE3Njk4MTc2MDB9.qvfebzx5jhjLQTrp6bf69WQQGV8dXD6g_Z9yHGuYXig"],"expect":"fune_session=eyJ0Ijoic2Vzc2lvbiIsInAiOiJvaWRjIiwicyI6IjExMDE2OTQ4NDQ3NDM4NjI3NjMzNCIsImUiOiJhZGFAZXhhbXBsZS5jb20iLCJuIjoiQWRhIExvdmVsYWNlIiwiaWF0IjoxNzY3MjI1NjAwLCJleHAiOjE3Njk4MTc2MDB9.qvfebzx5jhjLQTrp6bf69WQQGV8dXD6g_Z9yHGuYXig; Path=/; HttpOnly; Secure; SameSite=Lax; Max-Age=2592000"},
  {"fn":"sessionCookie","name":"an hour","args":["abc.def",3600],"expect":"fune_session=abc.def; Path=/; HttpOnly; Secure; SameSite=Lax; Max-Age=3600"},
  {"fn":"sessionCookie","name":"signing out","args":["",0],"expect":"fune_session=; Path=/; HttpOnly; Secure; SameSite=Lax; Max-Age=0"},
  {"fn":"sessionCookie","name":"zero seconds with a value expires it at once","args":["abc.def",0],"expect":"fune_session=abc.def; Path=/; HttpOnly; Secure; SameSite=Lax; Max-Age=0"},
  {"fn":"sessionCookie","name":"a value that would inject an attribute","args":["abc; Domain=evil.example"],"expectError":"a session cookie value is what createSession returned"},
  {"fn":"sessionCookie","name":"a negative lifetime","args":["abc.def",-1],"expectError":"maxAgeSeconds is a whole number of seconds, 0 or more, not -1"},
  {"fn":"sessionCookie","name":"a fractional lifetime","args":["abc.def",2.5],"expectError":"maxAgeSeconds is a whole number of seconds, 0 or more, not 2.5"},
  {"fn":"sessionCookie","name":"an empty value that would last","args":["",60],"expectError":"an empty session cookie only signs out: give maxAgeSeconds 0"}
]