Skip to content

roles and invites#3

Open
boazpoolman wants to merge 2 commits intodevelopfrom
roles-and-users-settings
Open

roles and invites#3
boazpoolman wants to merge 2 commits intodevelopfrom
roles-and-users-settings

Conversation

@boazpoolman
Copy link
Copy Markdown
Member

No description provided.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking that the roles, permissions and maby parts of the auth strategy can become it’s own package / plugin. That will give us a nice separation of concern, and allow other auth providers to use it and implement content API RBAC in Strapi. So it should have no dependency on Better Auth whatsoever. What do you think? @maccomaccomaccomacco

const { ApplicationError, ValidationError } = errors;

export default ({ strapi }: { strapi: Core.Strapi }) => {
const roleService = () =>
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a way to add this return type automatically. I’ll add it to your branch.

ctx.send({ data: { conditions: [], sections: layout } });
},

async createRole(ctx: { request: { body: unknown }; send: (body: unknown) => void }) {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These crud actions could probably be a factory controller

routes: [
{
method: "POST",
path: "/better-auth/invite/set-password",
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m wondering how much of this invite flow can be ‘native’ better auth. For example setting a password is a very common action.

const apiEntry = actionsMap[apiKey];
const controllerActions = apiEntry?.controllers?.[controllerName] ?? [];

const allowedActions = isSingle
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean custom controller actions are filtered out?


const userEmail = (user as { email: string }).email;

await strapi.documents(ACCOUNT_UID).create({
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should try to refrain from using the Document Service to interact with Better Auth data. I believe everything should be possible through their API.

name: "better-auth",
authenticate: async (ctx: ParameterizedContext): Promise<AuthResult> => {
try {
const authConfig = (strapi as unknown as { internal_config: Record<string, unknown> }).internal_config["better-auth"] as
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a type provided by Better Auth for this. I believe they call it ‘Auth’. I’m wondering if we can globally set this type so that people using the plugin get that type automatically. Just like the ‘strapi’ global.

* If config["better-auth"] is a function (strapi) => authInstance, call it with strapi
* and store the result. This allows the project config to use strapi for sendResetPassword etc.
*/
function ensureBetterAuthInitialized(strapi: Core.Strapi) {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed? Shouldn’t we just throw an error when no config was found?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants