-
-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: finish base implementations and session guard
- Loading branch information
1 parent
317601f
commit 564987d
Showing
37 changed files
with
678 additions
and
307 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* @adonisjs/auth | ||
* | ||
* (c) AdonisJS | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
import { configProvider } from '@adonisjs/core' | ||
import { RuntimeException } from '@poppinss/utils' | ||
import type { ApplicationService } from '@adonisjs/core/types' | ||
|
||
import { AuthManager } from '../src/auth/auth_manager.js' | ||
import type { AuthService } from '../src/auth/types.js' | ||
|
||
declare module '@adonisjs/core/types' { | ||
export interface ContainerBindings { | ||
'auth.manager': AuthService | ||
} | ||
} | ||
|
||
export default class AuthProvider { | ||
constructor(protected app: ApplicationService) {} | ||
|
||
register() { | ||
this.app.container.singleton('auth.manager', async () => { | ||
const authConfigProvider = this.app.config.get('auth') | ||
const config = await configProvider.resolve<any>(this.app, authConfigProvider) | ||
|
||
if (!config) { | ||
throw new RuntimeException( | ||
'Invalid config exported from "config/auth.ts" file. Make sure to use the defineConfig method' | ||
) | ||
} | ||
|
||
return new AuthManager(config) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* @adonisjs/auth | ||
* | ||
* (c) AdonisJS | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
import app from '@adonisjs/core/services/app' | ||
import { AuthService } from '../src/auth/types.js' | ||
|
||
let auth: AuthService | ||
|
||
/** | ||
* Returns a singleton instance of the Auth manager class | ||
*/ | ||
await app.booted(async () => { | ||
auth = await app.container.make('auth.manager') | ||
}) | ||
|
||
export { auth as default } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.