Bot releases are hidden (Show)
createHelpers()
for Shared ConfigurationsYou can now overwrite Deno KV OAuth's cookie properties. This functionality is handy in setups that require greater customization. E.g. A website that has a separate auth sub-domain like auth.exmaple.com
. These options can be set in the new createHelpers()
function. This will ensure consistent behaviour across your website by generating the full suite of helpers with a single, shared configuration. To get started, see the Get Started with Cookie Options README section.
The Fresh plugin was removed and replaced by the new Get Started with Fresh README section. The example uses the new createHelpers()
and clarifies how a self-implemented plugin would work and aims to shed light on extending it.
Previously, the session ID was only stored in a cookie sent to the client. This meant that the session ID could be imitated, posing a security risk. Now, the session ID is stored in the server's database. Checking the session ID database entry validates whether the session ID originated on the server. To migrate, await
getSessionId()
and signOut()
, which are now async:
// server.ts
import {
createGitHubOAuthConfig,
getSessionId,
handleCallback,
signIn,
signOut,
} from "https://deno.land/x/deno_kv_oauth@$VERSION/mod.ts";
const oauthConfig = createGitHubOAuthConfig();
async function handler(request: Request) {
const { pathname } = new URL(request.url);
switch (pathname) {
case "/oauth/signin":
return await signIn(request, oauthConfig);
case "/oauth/callback":
const { response } = await handleCallback(request, oauthConfig);
return response;
case "/oauth/signout":
- return signOut(request);
+ return await signOut(request);
case "/protected-route":
- return getSessionId(request) === undefined
+ return await getSessionId(request) === undefined
? new Response("Unauthorized", { status: 401 })
: new Response("You are allowed");
default:
return new Response(null, { status: 404 });
}
}
Deno.serve(handler);
createHelpers()
by @iuioiua in https://github.com/denoland/deno_kv_oauth/pull/255
getSessionId()
by @iuioiua in https://github.com/denoland/deno_kv_oauth/pull/254
cookieOptions
partial for signOut()
by @iuioiua in https://github.com/denoland/deno_kv_oauth/pull/249
cookieOptions
optional by @iuioiua in https://github.com/denoland/deno_kv_oauth/pull/252
OAuthSession
expiry compulsory by @iuioiua in https://github.com/denoland/deno_kv_oauth/pull/263
@$VERSION
from imports by @iuioiua in https://github.com/denoland/deno_kv_oauth/pull/256
@$VERSION
from imports by @iuioiua in https://github.com/denoland/deno_kv_oauth/pull/268
*-latest
platforms by @iuioiua in https://github.com/denoland/deno_kv_oauth/pull/264
Full Changelog: https://github.com/denoland/deno_kv_oauth/compare/v0.9.1...v0.10.0
Published by iuioiua about 1 year ago
setOAuthSession()
args stricter by @iuioiua in https://github.com/denoland/deno_kv_oauth/pull/246
signOut()
by @iuioiua in https://github.com/denoland/deno_kv_oauth/pull/244
isSecure()
to isHttps()
by @iuioiua in https://github.com/denoland/deno_kv_oauth/pull/242
Full Changelog: https://github.com/denoland/deno_kv_oauth/compare/v0.9.0...v0.9.1
Published by iuioiua about 1 year ago
clearOAuthSessionsAndTokens()
Since tokens are no longer stored in the database and OAuth session data expires, the clearOAuthSessionsAndTokens()
has been removed from Deno KV OAuth's API. In other words, the database will be kept clean automatically. We recommend running this function one last time before upgrading to this version.
OAuth2ClientConfig
InterfacePreviously, if needed, you had to import the OAuth2ClientConfig
interface from x/oauth2_client. Now, that interface is re-exported as part of Deno KV OAuth. This keeps the version of x/oauth2_client that Deno KV OAuth uses in alignment for free.
- import type { OAuth2ClientConfig } from "https://deno.land/x/oauth2_client/mod.ts";
import {
+ type OAuth2ClientConfig,
signIn,
handleCallback,
signOut,
} from "https://deno.land/x/deno_kv_oauth@$VERSION/mod.ts";
The documentation has been re-written to be clearer and more concise, with the aim of increasing the understandability of the module and how to use it.
clearOAuthSessionsAndTokens()
by @iuioiua in https://github.com/denoland/deno_kv_oauth/pull/230
OAuth2ClientConfig
interface by @iuioiua in https://github.com/denoland/deno_kv_oauth/pull/236
Secure
field in base cookie recipe by @iuioiua in https://github.com/denoland/deno_kv_oauth/pull/238
getRequiredEnv()
from mod.ts
by @iuioiua in https://github.com/denoland/deno_kv_oauth/pull/240
getSessionId()
from README by @iuioiua in https://github.com/denoland/deno_kv_oauth/pull/241
getAndDeleteOAuthSession()
by @iuioiua in https://github.com/denoland/deno_kv_oauth/pull/231
Full Changelog: https://github.com/denoland/deno_kv_oauth/compare/v0.8.0...v0.9.0
Published by iuioiua about 1 year ago
Previously, OAuth tokens were stored in the database in handleCallback()
and accessible through getSessionAccessToken()
. In most cases, access tokens are only ever used within the callback handler, so the storage and retrieval of OAuth tokens have been removed. OAuth tokens are still available in the tokens
property of the return object of handleCallback()
. In the edge case requiring storage of the OAuth tokens, one can still implement their solution within the callback handler.
This has significantly simplified the codebase and slightly increased the performance now that a database write is no longer happening in handleCallback()
. This has also opened up opportunities for further simplifications in the future.
To migrate, do the following: remove getSessionAccessToken()
and instead use accessToken
from handleCallback()
.
DENO_KV_PATH
Environment VariablePreviously, the path of the Deno KV instance could be controlled using the KV_PATH
environment variable. This environment variable has been renamed to DENO_KV_PATH
to align it with Deno Deploy's DENO_KV_ACCESS_TOKEN
.
To migrate, change use of the KV_PATH
environment variable to DENO_KV_PATH
:
- KV_PATH=:memory: deno run --unstable -A my_scipt.ts
+ DENO_KV_PATH=:memory: deno run --unstable -A my_scipt.ts
Deno KV now supports key expirations. After 10 minutes, an OAuth session entry in the database will be automatically deleted. With this and token storage being dropped, Deno KV OAuth will have a self-cleaning database without needing further action.
We recommend clearing the database after upgrading to this version of Deno KV OAuth:
import { clearOAuthSessionsAndTokens } from "https://deno.land/x/[email protected]/lib/clear_oauth_sessions_and_tokens.ts";
await clearOAuthSessionsAndTokens();
SignInOptions
interface by @iuioiua in https://github.com/denoland/deno_kv_oauth/pull/223
randomTokens()
test utility with randomTokensBody()
by @iuioiua in https://github.com/denoland/deno_kv_oauth/pull/229
Full Changelog: https://github.com/denoland/deno_kv_oauth/compare/v0.7.0...v0.8.0
Published by iuioiua about 1 year ago
This release contains important bug fixes that previously caused extraneous refresh token requests to be sent to the provider and token expiry miscalculations. These fixes also improve performance. Thank you to @mitchwadair for fixing these.
Previously, functions across the library created and consumed the OAuth2Client
class. Now, the library uses the simpler OAuth2ClientConfig
interface and OAuth2Client
instances are created internally when needed. This includes provider-related functions. To migrate your codebase:
// Sign-in, callback and sign-out handlers
import {
- createGitHubOAuth2Client,
+ createGitHubOAuthConfig,
handleCallback,
signIn,
signOut,
} from "https://deno.land/x/deno_kv_oauth@$VERSION/mod.ts";
- const oauth2Client = createGitHubOAuth2Client();
+ const oauthConfig = createGitHubOAuthConfig();
async function handleSignIn(request: Request) {
- return await signIn(request, oauth2Client);
+ return await signIn(request, oauthConfig);
}
async function handleOAuth2Callback(request: Request) {
- return await handleCallback(request, oauth2Client);
+ return await handleCallback(request, oauthConfig);
}
async function handleSignOut(request: Request) {
return await signOut(request);
}
Thank you to @jollytoad for the suggestion and initial PR.
OAuth2ClientConfig
instead of OAuth2Client
by @iuioiua in https://github.com/denoland/deno_kv_oauth/pull/207
expiresIn
calculation in toTokens()
by @mitchwadair in https://github.com/denoland/deno_kv_oauth/pull/200
_types.ts
to types.ts
by @iuioiua in https://github.com/denoland/deno_kv_oauth/pull/204
oauthConfig
references by @iuioiua in https://github.com/denoland/deno_kv_oauth/pull/217
/src
to /lib
by @iuioiua in https://github.com/denoland/deno_kv_oauth/pull/218
cov:clean
task by @iuioiua in https://github.com/denoland/deno_kv_oauth/pull/216
cov:gen
and cov:view
tasks by @iuioiua in https://github.com/denoland/deno_kv_oauth/pull/205
Update dependencies
workflow by @iuioiua in https://github.com/denoland/deno_kv_oauth/pull/208
Full Changelog: https://github.com/denoland/deno_kv_oauth/compare/v0.6.1...v0.7.0
Published by iuioiua about 1 year ago
setTokens()
by @iuioiua in https://github.com/denoland/deno_kv_oauth/pull/178
Full Changelog: https://github.com/denoland/deno_kv_oauth/compare/v0.6.0...v0.6.1
Published by iuioiua about 1 year ago
Full Changelog: https://github.com/denoland/deno_kv_oauth/compare/v0.5.0...v0.6.0
Published by iuioiua about 1 year ago
BREAKING CHANGE: the redirectUrl
parameter for handleCallback()
and signOut()
have been removed. Please see the "Redirect URL after Sign-In or Sign-Out" section in the README on how the new success URL feature works.
stored_tokens_by_session
index by @iuioiua in https://github.com/denoland/deno_kv_oauth/pull/169
deno task check:types
to check entire codebase by @iuioiua in https://github.com/denoland/deno_kv_oauth/pull/163
[email protected]
by @github-actions in https://github.com/denoland/deno_kv_oauth/pull/166
--trace-ops
to test
task by @iuioiua in https://github.com/denoland/deno_kv_oauth/pull/167
Full Changelog: https://github.com/denoland/deno_kv_oauth/compare/v0.4.0...v0.5.0
Published by iuioiua about 1 year ago
clearOAuthSessionsAndTokens()
by @iuioiua in https://github.com/denoland/deno_kv_oauth/pull/160
CONTRIBUTING.md
by @iuioiua in https://github.com/denoland/deno_kv_oauth/pull/156
COOKIE_BASE
type by @iuioiua in https://github.com/denoland/deno_kv_oauth/pull/159
Full Changelog: https://github.com/denoland/deno_kv_oauth/compare/v0.3.0...v0.4.0
Published by iuioiua about 1 year ago
getSessionId()
by @iuioiua in https://github.com/denoland/deno_kv_oauth/pull/147
Full Changelog: https://github.com/denoland/deno_kv_oauth/compare/v0.2.8...v0.3.0
Published by iuioiua about 1 year ago
signIn()
by @adoublef in https://github.com/denoland/deno_kv_oauth/pull/141
createAuth0OAuth2Client()
by @zachauten in https://github.com/denoland/deno_kv_oauth/pull/138
Deno.serve()
in demo by @iuioiua in https://github.com/denoland/deno_kv_oauth/pull/142
[email protected]
by @iuioiua in https://github.com/denoland/deno_kv_oauth/pull/143
Full Changelog: https://github.com/denoland/deno_kv_oauth/compare/v0.2.7...v0.2.8
Published by iuioiua over 1 year ago
Full Changelog: https://github.com/denoland/deno_kv_oauth/compare/v0.2.6...v0.2.7
Published by iuioiua over 1 year ago
createOktaOAuth2Client()
by @jollytoad in https://github.com/denoland/deno_kv_oauth/pull/129
null
on expired refresh token by @iuioiua in https://github.com/denoland/deno_kv_oauth/pull/131
Full Changelog: https://github.com/denoland/deno_kv_oauth/compare/v0.2.5...v0.2.6
Published by iuioiua over 1 year ago
undefined
instead of null
from getSessionId()
by @iuioiua in https://github.com/denoland/deno_kv_oauth/pull/126
deno.lock
changes by @iuioiua in https://github.com/denoland/deno_kv_oauth/pull/122
Full Changelog: https://github.com/denoland/deno_kv_oauth/compare/v0.2.4...v0.2.5
Published by iuioiua over 1 year ago
createPatreonOAuth2Client()
by @j3lte in https://github.com/denoland/deno_kv_oauth/pull/98
createNotionOAuth2Client()
by @j3lte in https://github.com/denoland/deno_kv_oauth/pull/95
createSpotifyOAuth2Client()
by @Jabolol in https://github.com/denoland/deno_kv_oauth/pull/110
src
files by @iuioiua in https://github.com/denoland/deno_kv_oauth/pull/104
isSecure()
by @iuioiua in https://github.com/denoland/deno_kv_oauth/pull/114
Full Changelog: https://github.com/denoland/deno_kv_oauth/compare/v0.2.3...v0.2.4
Published by iuioiua over 1 year ago
createFacebookOAuth2Client()
by @j3lte in https://github.com/denoland/deno_kv_oauth/pull/94
createDropboxOAuth2Client()
by @j3lte in https://github.com/denoland/deno_kv_oauth/pull/93
createOAuth2Client()
tests by @iuioiua in https://github.com/denoland/deno_kv_oauth/pull/100
Full Changelog: https://github.com/denoland/deno_kv_oauth/compare/v0.2.2...v0.2.3
Published by iuioiua over 1 year ago
getSessionId()
by @iuioiua in https://github.com/denoland/deno_kv_oauth/pull/90
Full Changelog: https://github.com/denoland/deno_kv_oauth/compare/v0.2.1...v0.2.2
Published by iuioiua over 1 year ago
The -beta
suffix and pre-release status are being dropped in this release. This module is still in beta but moving towards a stable release.
KV_PATH
environment variable by @iuioiua in https://github.com/denoland/deno_kv_oauth/pull/89
Full Changelog: https://github.com/denoland/deno_kv_oauth/compare/v0.2.0-beta...v0.2.1
Published by iuioiua over 1 year ago
createXOAuth2Client()
by @iuioiua in https://github.com/denoland/deno_kv_oauth/pull/78
getSessionId()
checks KV by @iuioiua in https://github.com/denoland/deno_kv_oauth/pull/72
max-age
be 10 mins by @iuioiua in https://github.com/denoland/deno_kv_oauth/pull/71
additionalOAuth2ClientConfig
where redirectUri
and/or scope
are required by @iuioiua in https://github.com/denoland/deno_kv_oauth/pull/80
cov/
from lint, test and format by @iuioiua in https://github.com/denoland/deno_kv_oauth/pull/73
Full Changelog: https://github.com/denoland/deno_kv_oauth/compare/v0.1.8-beta...v0.2.0-beta
Published by iuioiua over 1 year ago
getSessionAccessToken()
with automatic refresh by @iuioiua in https://github.com/denoland/deno_kv_oauth/pull/66
Full Changelog: https://github.com/denoland/deno_kv_oauth/compare/v0.1.7-beta...v0.1.8-beta