Skip to content

Conversation

@Convly
Copy link
Member

@Convly Convly commented Jan 28, 2025

What does it do?

Simplifies the auth configuration by flattening the properties.

Basically

strapi({
  baseURL: '...',
  auth: {
    strategy: 'api-token',
    options: {
      token: '<token>'
    }
  }
})

becomes

strapi({
  baseURL: '...',
  auth: '<token>'
})

Why is it needed?

Improve the developer experience when using the SDK

How to test it?

See example above, it should work the same for the undocumented users-permission provider

@Convly Convly added pr: feature New or updates to features source: client Source is the main client object labels Jan 28, 2025
@hanpaine hanpaine added the flag: 💥 breaking change This PR contains breaking changes and should only be merged for major versions/pre-stable label Jan 29, 2025
Copy link
Contributor

@innerdvations innerdvations left a comment

Choose a reason for hiding this comment

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

LGTM but haven't tested it out

@Convly Convly force-pushed the feat/better-auth-config-api branch from bc165c2 to 8fbcbbf Compare January 29, 2025 14:54
@Convly Convly requested a review from innerdvations January 29, 2025 14:56
Copy link
Contributor

@innerdvations innerdvations left a comment

Choose a reason for hiding this comment

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

Even better now :)

I will try to test it tomorrow, not sure I have time today

@jhoward1994
Copy link
Contributor

Looks good 👍🏻

I just can't get my head round how you would provide a different auth provider? Or even how auth providers would differ now if the auth property is just a string token?

@Convly
Copy link
Member Author

Convly commented Jan 30, 2025

Looks good 👍🏻

I just can't get my head round how you would provide a different auth provider? Or even how auth providers would differ now if the auth property is just a string token?

The idea was to simplify things while we only have one authentication method while keeping some space and flexibility in case we want to add something later.

For instance if we end up having multiple providers people can use, we could introduce an authStrategy property and auth would be "unknown" to represent whatever param the strategy expects.

Another option in the future that this solution allows, is to keep the auth to api token forever and delegate custom auth to extensions/plugins (interacting with an auth API to switch auth strategies)

To summarize this abstract the current auth API to the minimum/simplest so that we have more option in the future and we don't limit ourselves with breaking changes

@Convly Convly merged commit dce8eb1 into main Jan 30, 2025
7 checks passed
@Convly Convly deleted the feat/better-auth-config-api branch January 30, 2025 12:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

flag: 💥 breaking change This PR contains breaking changes and should only be merged for major versions/pre-stable pr: feature New or updates to features source: client Source is the main client object

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants