Laktos
Laktos
BABetter Auth
Created by Laktos on 12/26/2024 in #help
Multiple roles for users in organizations
It’s coming out in 1.2 so should be around the corner! It’s in beta now. But as of right now, it’s not supported.
10 replies
BABetter Auth
Created by Mad_angle on 1/1/2025 in #help
Ways to authenticate non-js api?
Hey! I haven't used the bearer token but the JWT token is possible to verify through the public key of the JWKs, if using a compatible (asymmetric) encryption method, like RS256. The principles are here: https://auth0.com/blog/navigating-rs256-and-jwks/ And then regarding how it's done in your case, you'll probably want "jsonwebtokens", and then use "verify()" from there, and then use the public key which you can get from the better-auth BE API "jwks()" (which as far as I could tell only gave the public part) and converting it to PEM, and then passing that to the verify function. Just make sure that you're not leaking any private key. I was just testing around with this, not using it atm so can't help much more than this.
5 replies
BABetter Auth
Created by Dawson on 12/26/2024 in #help
Hono + Nextjs
Tried using windsurf to setup a nuxt repo with better-auth and it's horrible at it tbh. I would have imagined it would have the LSP info to be able to know which methods etc are available from the package but it hallucinates a ton and just creates a mess. But perhaps it's better as you say after initial implementation, to do additions etc
52 replies
BABetter Auth
Created by Dawson on 12/26/2024 in #help
Hono + Nextjs
Sure is! Damn, makes sense though. I mean I was too with VSCode, used the vim plugin for a year. Those plugins are a great start, the motions are essential. I mean now I use it so that I can chat or edit the current file. But yknow that’s a pr good idea, because since it’s a monorepo I should be able to limit it to the ”current service”. Will be a bit handicapped, no access to shared types/utils but maybe better than nothing. A lil worried about token spending when doing that though. I think it can be vast differences using the same model. Like better chunking strategies in RAG will yield much better results. So maybe windsurf is onto something. What made you go back?
52 replies
BABetter Auth
Created by Laktos on 12/26/2024 in #help
Can't list organizations on Vue client
No description
2 replies
BABetter Auth
Created by Dawson on 12/26/2024 in #help
Hono + Nextjs
I did use the vim extension. But it just was so bad for keyboard-first overall tbh. Or at least in terms of customizing it for navigation between different panes and moving around outside of the actual text editing. I guess the biggest issue was really the lack of deep mode-recognizion. Like in nvim the mode is respected everywhere, if you're in insert mode, then you only get the keybindings for insert mode. I didn't quite get that to work properly in Cursor, or VSCode. And the thing is that I'm not into nvim purely for the bindings. It's that I've built the perfect little editor with only what I want and around 50ms startup time. Going to VSCode / Cursor feels very bloated now. It's just too much stuff that I'll never use and all the repo-navigation is just so much better with telescope.nvim and mini.files than any other IDE that I've used. I've got an AI plugin using OpenAI too that can be workspace-aware, but my repo is too big for that (>400k LOC). And the same applies to Cursor. Kinda wish I could switch, but also very happy with my current setup. We'll see, maybe I'll try windsurf, the whole agentic thing seems cool.
52 replies
BABetter Auth
Created by Laktos on 12/26/2024 in #help
Multiple roles for users in organizations
Oh but I see what you mean though with the session. If I just write a lil function for getting the permissions from the roles, and get the roles from the database, I can get the permissions directly in the getSession-response, which is greeat for checking for my endpoint decorators
10 replies
BABetter Auth
Created by Dawson on 12/26/2024 in #help
Hono + Nextjs
Lmaoo 😢 Damn windsurf looks cool! I've tried Cursor but I just became mad at it. I just can't switch because I love my nvim too much. I guess I might be missing out on some stuff though. You feel like it's overall net-positive with the AI IDE:s? To me it usually feels like I still have to put as much time in total as I would just writing it myself. Perhaps getting a few prompts into GPT o1 or Claude 3.5 for some thing which I just can't be bothered to write myself.
52 replies
BABetter Auth
Created by Dawson on 12/26/2024 in #help
Hono + Nextjs
Man what do you use for IDE? That’s bonkers. And what kind of intellisense tasks? Doing LSP-based replacements repo-wide or something? Kinda makes sense that it could be a little slow though, depending on your language server config and the size of the repo
52 replies
BABetter Auth
Created by Laktos on 12/26/2024 in #help
Multiple roles for users in organizations
Hm yeah that’s kind of a bummer. Like in RBAC it’s commonplace to have multiple roles per user (/member). Going to feature request that then. Not using an endpoint for validating the JWT. That’s the neat thing, I’ve got a public key to verify it with, which I had hoped I could do with the session cookie too. But perhaps it’ll be alright since I will most likely do this in an auth module that’ll be included in all my services. Then they’ll all have access to the database and hence, the getSession. Ok the custom session could come in handy, but I don’t think it can be used to solve the thing with the permissions.
10 replies
BABetter Auth
Created by Dawson on 12/26/2024 in #help
Hono + Nextjs
Haha nah it's probably quite rare to have those kinds of issues
52 replies
BABetter Auth
Created by Dawson on 12/26/2024 in #help
Hono + Nextjs
Sounds a lil jank yes! But if it works it works y'know. Seems like you'd lose quite a bit of the speed-benefits of hono no?
52 replies
BABetter Auth
Created by Laktos on 12/26/2024 in #help
Multiple roles for users in organizations
Hey Bekacru! Thanks for the answers. I'm aware about the first thing, that it's on the member level, but the thing is that it's in "singular", i.e. you can only have one role per organization. What I was getting at in my message was kind of a workaround where I would manually extend the user data, which would not be on the member level, since the member can't be extended, to my knowledge. Yep, I used that the definePayload one but I guess the real issue is how to get those permissions/roles for attaching. Yeah I hope that's true! I just need to find a good way to integrate it with my current auth setup, which uses JWT. Like, the thing is that it looks like from this:
import { createAuthMiddleware, sessionMiddleware } from "better-auth/plugins";

const myPlugin = ()=>{
return {
id: "my-plugin",
endpoints: {
getHelloWorld: createAuthEndpoint("/my-plugin/hello-world", {
method: "GET",
use: [sessionMiddleware], //[!code highlight]
}, async(ctx) => {
const session = ctx.context.session;
return ctx.json({
message: "Hello World"
})
})
}
} satisfies BetterAuthPlugin
}
import { createAuthMiddleware, sessionMiddleware } from "better-auth/plugins";

const myPlugin = ()=>{
return {
id: "my-plugin",
endpoints: {
getHelloWorld: createAuthEndpoint("/my-plugin/hello-world", {
method: "GET",
use: [sessionMiddleware], //[!code highlight]
}, async(ctx) => {
const session = ctx.context.session;
return ctx.json({
message: "Hello World"
})
})
}
} satisfies BetterAuthPlugin
}
That one would have to do this for all endpoints, but perhaps I'm missing something about how to properly use plugins. I gotta validate the session somehow when I get a request on an endpoint which isn't the Better Auth endpoints. Like right now I've got a setup that verifies the JWT against a public key on every endpoint, through a decorator. Wouldn't be hard to forge one if there's no actual check against either the session cookie cache on the server or the one in the DB.
10 replies
BABetter Auth
Created by Dawson on 12/26/2024 in #help
Hono + Nextjs
Oh, how come you can't use it if you're using hono?
52 replies
BABetter Auth
Created by Dawson on 12/26/2024 in #help
Hono + Nextjs
Ahh alright. That's a good start tbh. But then it might be pr good to get some service that can do distributed load testing.
52 replies
BABetter Auth
Created by Dawson on 12/26/2024 in #help
Hono + Nextjs
Cool! Another question then, what have you been using to load-test it/do the fake traffic? I kinda need something like that as well. Ah, alright. Oo just learned that NestJS supports bun. Getting kinda intrigued
52 replies
BABetter Auth
Created by Dawson on 12/26/2024 in #help
Hono + Nextjs
Alright, npnp! How's Hono? Used it for bigger projects or experimenting with it?
52 replies
BABetter Auth
Created by Dawson on 12/26/2024 in #help
Hono + Nextjs
The docs have an example of this in the "installation" section. And as stated: "If you're using a separate client and server setup, make sure to install Better Auth in both parts of your project." The final step of the installation is "create client instance", which would be your FE.
52 replies
BABetter Auth
Created by Imam on 12/26/2024 in #help
Cors Error on Elysia with Node Adapter
Check that your NEXT PUBLIC WEB BASE URL is in fact http://localhost:3000
22 replies