Skip to content

Commit ee388a8

Browse files
Improve oauth and add way too fancy redirect settings (#8)
* Improve oauth and add way too fancy redirect * Polish up code a bit * add todo
1 parent 9e4a121 commit ee388a8

File tree

21 files changed

+5836
-69
lines changed

21 files changed

+5836
-69
lines changed

astro-authproto/README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,14 @@ Bluesky and beyond.
1919
- [ ] Comment the whole Auth files
2020
- [ ] Improve config and make it make sense
2121
- [x] Figure out how to turn AstroDB into an option
22-
- [ ] Add option to redirect logged in/logged out user to a chosen page
22+
- [x] Add option to redirect logged in/logged out user to a chosen page
2323
- [ ] Explain how to intercept logged out/logged in events so you can do things
2424
- [ ] Figure out how to make types correctly signal Astro.locals.loggedInUser can be null
25-
- [ ] Fix the state bits in the oauth login route
25+
- [x] Fix the state bits in the oauth login route
2626
- [x] Figure out what's up with weird amount of implementations in lib/
27-
- [ ] Clean up client-metadata duplication
27+
- [x] Clean up client-metadata duplication
2828
- [ ] Rename genericData to writeData
29+
- [ ] Add lists of current permissions
2930

3031
// Tip!
3132
Want to see what gets saved by the storage? Use
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# build output
2+
dist/
3+
# generated types
4+
.astro/
5+
6+
# dependencies
7+
node_modules/
8+
9+
# logs
10+
npm-debug.log*
11+
yarn-debug.log*
12+
yarn-error.log*
13+
pnpm-debug.log*
14+
15+
16+
# environment variables
17+
.env
18+
.env.production
19+
20+
# macOS-specific files
21+
.DS_Store
22+
23+
# jetbrains setting folder
24+
.idea/
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# How to use `@fujocoded/authproto` in practice!
2+
3+
See files.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// @ts-check
2+
import { defineConfig } from "astro/config";
3+
import authProto, {
4+
LOGGED_IN_DID_TEMPLATE,
5+
REDIRECT_TO_REFERER_TEMPLATE,
6+
} from "@fujocoded/authproto";
7+
8+
// https://astro.build/config
9+
export default defineConfig({
10+
output: "server",
11+
session: {
12+
driver: "fs",
13+
},
14+
integrations: [
15+
authProto({
16+
applicationName: "Authproto test",
17+
applicationDomain: "fujocoded.com",
18+
defaultDevUser: "essentialrandom.bsky.social",
19+
scopes: {
20+
email: true,
21+
directMessages: true,
22+
additionalScopes: ["transition:generic"],
23+
},
24+
redirects: {
25+
// You can use the following template variables in the redirect URLs:
26+
//
27+
// {referer} => The URL of the page the user logged in/out from
28+
// {loggedInUser.did} => The logged in user's DID
29+
// {loggedInUser.handle} => The logged in user's handle
30+
//
31+
// They also come nicely packaged as exported variables.
32+
afterLogin: `/hello?did=${LOGGED_IN_DID_TEMPLATE}`,
33+
afterLogout: `${REDIRECT_TO_REFERER_TEMPLATE}?reason=logged-out`,
34+
// If you don't need to use these, you can simply use a string instead.
35+
// afterLogout: "/bye",
36+
},
37+
}),
38+
],
39+
});

0 commit comments

Comments
 (0)