Skip to content

feat(authentication): Add setup method for auth strategies - #1611

Merged
daffl merged 3 commits into
feathersjs:dovefrom
vonagam:feat-auth-strategy-setup
Mar 30, 2022
Merged

feat(authentication): Add setup method for auth strategies#1611
daffl merged 3 commits into
feathersjs:dovefrom
vonagam:feat-auth-strategy-setup

Conversation

@vonagam

@vonagam vonagam commented Oct 9, 2019

Copy link
Copy Markdown
Member

Add setup method to AuthenticationStrategy by analogy with service setup. More convenient alternative to setAuthentication/setApplication/setName and removes the need for getters, since it ensures that all services are already registered by the time of a call.

For example, right now every time you get entityService in a strategy you call:

  1. AuthenticationBaseStrategy.configuration
  2. AuthenticationBase.configuration
  3. Object.assign and app.get
  4. app.service

All of those calls can be done once in setup method instead doing them every time.

Also fixed small inconsistencies in app.setup:

  1. Moved this line up since otherwise a service registered in other service setup call will not get setup call.

  2. Moved those lines down so that setup call for a dynamically registered service happens after the service is registered just like for a usual service.

@vonagam
vonagam force-pushed the feat-auth-strategy-setup branch from d50263b to f818a04 Compare December 15, 2019 22:04
@jnardone

jnardone commented Feb 4, 2020

Copy link
Copy Markdown
Contributor

couldn't you do all of this in setApplication?

@vonagam

vonagam commented Feb 4, 2020

Copy link
Copy Markdown
Member Author

it ensures that all services are already registered by the time of a call

setApplication (with setName, setAuthentication and verifyConfiguration) is called in register method, before setup, and not everything is set up at that point (not all services registered).

Why have those separate methods when one will do? In Service you do not have setApplication, setName or verifyConfiguration, only setup.

@jnardone

jnardone commented Feb 4, 2020

Copy link
Copy Markdown
Contributor

Good points. This would be very useful for a project I'm currently working on.

@daffl daffl closed this Jul 11, 2020
@daffl

daffl commented Jul 11, 2020

Copy link
Copy Markdown
Member

Hm, sorry I'm not sure why this got closed. Going to reopen but will review again to add in v5 (which will also have asynchronous application setup).

@daffl daffl reopened this Jul 11, 2020
@vonagam
vonagam force-pushed the feat-auth-strategy-setup branch from f818a04 to 4a5b7ff Compare October 27, 2021 12:07
@vonagam
vonagam changed the base branch from master to dove October 27, 2021 12:08
@vonagam

vonagam commented Oct 27, 2021

Copy link
Copy Markdown
Member Author

Rebased.

@daffl daffl changed the title feat: Add setup method for auth strategies feat(authentication): Add setup method for auth strategies Mar 30, 2022
@daffl
daffl merged commit a3c3581 into feathersjs:dove Mar 30, 2022
@daffl

daffl commented Mar 30, 2022

Copy link
Copy Markdown
Member

Will go out in the next prerelease. Better late than never I guess, sorry about that 😄

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.

3 participants