Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update AWS Cognito authentication example for 2.x.x #55

Merged
merged 5 commits into from
Jan 28, 2024

Conversation

adam-fowler
Copy link
Member

@adam-fowler adam-fowler commented Jan 23, 2024

Uses result builder router

@adam-fowler adam-fowler requested a review from Joannis January 23, 2024 16:19
Comment on lines 46 to 76
/* extension HBApplication {
/// configure your application
/// add middleware
/// setup the encoder/decoder
/// add your routes
public func configure() throws {
let env = HBEnvironment()

// setup Soto
self.aws.client = AWSClient(httpClientProvider: .createNewWithEventLoopGroup(self.eventLoopGroup))
self.aws.cognitoIdentityProvider = CognitoIdentityProvider(client: self.aws.client, region: .euwest1)

// setup SotoCognitoAuthentication
guard let userPoolId = env.get("cognito_user_pool_id"),
let clientId = env.get("cognito_client_id")
else {
preconditionFailure("Requires \"cognito_user_pool_id\" and \"cognito_client_id\" environment variables")
}
let config = CognitoConfiguration(
userPoolId: userPoolId,
clientId: clientId,
clientSecret: env.get("cognito_client_secret"),
cognitoIDP: self.aws.cognitoIdentityProvider,
adminClient: true
)
self.cognito.authenticatable = CognitoAuthenticatable(configuration: config)

let userController = UserController()
userController.addRoutes(to: self.router.group("user"))
}
} */
Copy link
Member

Choose a reason for hiding this comment

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

Commented code

@adam-fowler adam-fowler merged commit 6cc2e32 into 2.x.x Jan 28, 2024
1 check passed
@adam-fowler adam-fowler deleted the 2.x.x-auth-cognito branch January 28, 2024 10:25
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