soto-project / soto-cognito-authentication-kit Goto Github PK
View Code? Open in Web Editor NEWAuthenticating with AWS Cognito
License: Apache License 2.0
Authenticating with AWS Cognito
License: Apache License 2.0
I believe this code to be incorrect. When setting requireAuthenticatedClient=false, the request is still being made to initAuthRequest with authFlow: .adminUserPasswordAuth, which results in the error: "InvalidParameterException: Initiate Auth method not supported." I believe it should be setting it to .userPasswordAuth.
public func authenticate(
username: String,
password: String,
requireAuthenticatedClient: Bool = true,
clientMetadata: [String: String]? = nil,
context: CognitoContextData,
on eventLoop: EventLoop
) -> EventLoopFuture<CognitoAuthenticateResponse> {
var authParameters : [String: String] = [
"USERNAME":username,
"PASSWORD": password
]
authParameters["SECRET_HASH"] = secretHash(username: username)
return self.initiateAuthRequest(authFlow: .adminUserPasswordAuth,
authParameters: authParameters,
requireAuthenticatedClient: requireAuthenticatedClient,
clientMetadata: clientMetadata,
context: context,
on: eventLoop)
}
not a String
Hi Adam,
Is there anyway to be able to use soto-cognito and support IOS 12 or alternative.
Thank you in advance.
Xcode 11.4 fails to resolve three packages, including BigNum.
Xcode 11.3.1 fails altogether to fetch tag 1.0.0-rc.1
.
Installing from master
does work, but based on version number/release is the default option, so it caused me a lot of head-scratching.
Hi,
I'm trying to use your toolkit to add AWS auth to a new iOS project. It looks like it might be the better tool (though young) for the task, but iOS isn't building with some undefined symbol errors.
Showing Recent Errors Only
Build target CJWTKitBoringSSL of project aws-cognito-authentication-kit with configuration Debug
Ld /Users/william.dillon/Library/Developer/Xcode/DerivedData/aws-cognito-authentication-kit-dpfwwoteavphsseamybdgruuvkal/Build/Products/Debug-iphoneos/CJWTKitBoringSSL.framework/CJWTKitBoringSSL normal arm64 (in target 'CJWTKitBoringSSL' from project 'aws-cognito-authentication-kit')
cd /Users/william.dillon/Documents/source/racepoint/aws-cognito-authentication-kit
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -target arm64-apple-ios8.0 -dynamiclib -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.4.sdk -L/Users/william.dillon/Library/Developer/Xcode/DerivedData/aws-cognito-authentication-kit-dpfwwoteavphsseamybdgruuvkal/Build/Products/Debug-iphoneos -F/Users/william.dillon/Library/Developer/Xcode/DerivedData/aws-cognito-authentication-kit-dpfwwoteavphsseamybdgruuvkal/Build/Products/Debug-iphoneos -F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Frameworks -filelist /Users/william.dillon/Library/Developer/Xcode/DerivedData/aws-cognito-authentication-kit-dpfwwoteavphsseamybdgruuvkal/Build/Intermediates.noindex/aws-cognito-authentication-kit.build/Debug-iphoneos/CJWTKitBoringSSL.build/Objects-normal/arm64/CJWTKitBoringSSL.LinkFileList -install_name @rpath/CJWTKitBoringSSL.framework/CJWTKitBoringSSL -Xlinker -rpath -Xlinker /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx -dead_strip -Xlinker -object_path_lto -Xlinker /Users/william.dillon/Library/Developer/Xcode/DerivedData/aws-cognito-authentication-kit-dpfwwoteavphsseamybdgruuvkal/Build/Intermediates.noindex/aws-cognito-authentication-kit.build/Debug-iphoneos/CJWTKitBoringSSL.build/Objects-normal/arm64/CJWTKitBoringSSL_lto.o -Xlinker -export_dynamic -Xlinker -no_deduplicate -fembed-bitcode-marker -Xlinker -dependency_info -Xlinker /Users/william.dillon/Library/Developer/Xcode/DerivedData/aws-cognito-authentication-kit-dpfwwoteavphsseamybdgruuvkal/Build/Intermediates.noindex/aws-cognito-authentication-kit.build/Debug-iphoneos/CJWTKitBoringSSL.build/Objects-normal/arm64/CJWTKitBoringSSL_dependency_info.dat -o /Users/william.dillon/Library/Developer/Xcode/DerivedData/aws-cognito-authentication-kit-dpfwwoteavphsseamybdgruuvkal/Build/Products/Debug-iphoneos/CJWTKitBoringSSL.framework/CJWTKitBoringSSL
Undefined symbols for architecture arm64:
"_CJWTKitBoringSSL_gcm_gmult_v8", referenced from:
_CJWTKitBoringSSL_CRYPTO_ghash_init in gcm.o
"_CJWTKitBoringSSL_gcm_init_neon", referenced from:
_CJWTKitBoringSSL_CRYPTO_ghash_init in gcm.o
"_CJWTKitBoringSSL_sha256_block_data_order", referenced from:
_CJWTKitBoringSSL_SHA256_Update in sha256.o
_CJWTKitBoringSSL_SHA256_Final in sha256.o
_CJWTKitBoringSSL_SHA256_Transform in sha256.o
_CJWTKitBoringSSL_SHA256_TransformBlocks in sha256.o
"_CJWTKitBoringSSL_gcm_ghash_neon", referenced from:
_CJWTKitBoringSSL_CRYPTO_ghash_init in gcm.o
"_CJWTKitBoringSSL_vpaes_cbc_encrypt", referenced from:
_aes_init_key in e_aes.o
"_CJWTKitBoringSSL_aes_hw_ctr32_encrypt_blocks", referenced from:
_CJWTKitBoringSSL_aes_ctr_set_key in e_aes.o
_aes_init_key in e_aes.o
"_CJWTKitBoringSSL_aes_hw_cbc_encrypt", referenced from:
_CJWTKitBoringSSL_AES_cbc_encrypt in mode_wrappers.o
_aes_init_key in e_aes.o
"_CJWTKitBoringSSL_bn_mul_mont", referenced from:
_CJWTKitBoringSSL_BN_mod_mul_montgomery in montgomery.o
_CJWTKitBoringSSL_bn_mod_mul_montgomery_small in montgomery.o
"_CJWTKitBoringSSL_aes_hw_set_decrypt_key", referenced from:
_CJWTKitBoringSSL_AES_set_decrypt_key in aes.o
_aes_init_key in e_aes.o
"_CJWTKitBoringSSL_vpaes_set_decrypt_key", referenced from:
_CJWTKitBoringSSL_AES_set_decrypt_key in aes.o
_aes_init_key in e_aes.o
"_CJWTKitBoringSSL_sha1_block_data_order", referenced from:
_CJWTKitBoringSSL_SHA1_Update in sha1.o
_CJWTKitBoringSSL_SHA1_Final in sha1.o
_CJWTKitBoringSSL_SHA1_Transform in sha1.o
"_CJWTKitBoringSSL_gcm_ghash_v8", referenced from:
_CJWTKitBoringSSL_CRYPTO_ghash_init in gcm.o
"_CJWTKitBoringSSL_vpaes_ctr32_encrypt_blocks", referenced from:
_CJWTKitBoringSSL_aes_ctr_set_key in e_aes.o
_aes_init_key in e_aes.o
"_CJWTKitBoringSSL_aes_hw_set_encrypt_key", referenced from:
_CJWTKitBoringSSL_AES_set_encrypt_key in aes.o
_CJWTKitBoringSSL_aes_ctr_set_key in e_aes.o
_aes_init_key in e_aes.o
"_CJWTKitBoringSSL_aes_hw_decrypt", referenced from:
_CJWTKitBoringSSL_AES_decrypt in aes.o
_aes_init_key in e_aes.o
"_CJWTKitBoringSSL_sha512_block_data_order", referenced from:
_CJWTKitBoringSSL_SHA512_Update in sha512.o
_CJWTKitBoringSSL_SHA512_Final in sha512.o
_CJWTKitBoringSSL_SHA512_Transform in sha512.o
"_CJWTKitBoringSSL_gcm_gmult_neon", referenced from:
_CJWTKitBoringSSL_CRYPTO_ghash_init in gcm.o
"_CJWTKitBoringSSL_aes_hw_encrypt", referenced from:
_CJWTKitBoringSSL_AES_encrypt in aes.o
_CJWTKitBoringSSL_aes_ctr_set_key in e_aes.o
_aes_init_key in e_aes.o
"_CJWTKitBoringSSL_vpaes_decrypt", referenced from:
_CJWTKitBoringSSL_AES_decrypt in aes.o
_aes_init_key in e_aes.o
"_CJWTKitBoringSSL_vpaes_set_encrypt_key", referenced from:
_CJWTKitBoringSSL_AES_set_encrypt_key in aes.o
_CJWTKitBoringSSL_aes_ctr_set_key in e_aes.o
_aes_init_key in e_aes.o
"_CJWTKitBoringSSL_vpaes_encrypt", referenced from:
_CJWTKitBoringSSL_AES_encrypt in aes.o
_CJWTKitBoringSSL_aes_ctr_set_key in e_aes.o
_aes_init_key in e_aes.o
"_CJWTKitBoringSSL_gcm_init_v8", referenced from:
_CJWTKitBoringSSL_CRYPTO_ghash_init in gcm.o
"_CJWTKitBoringSSL_ChaCha20_ctr32", referenced from:
_CJWTKitBoringSSL_CRYPTO_chacha_20 in chacha.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
At first I thought it was just that those functions were locked behind #ifdef
s, but I think those paths aren't really common (there are other errors that pop up that give me the impression that people don't actually use them.
Anyway, I'm wondering if you've tried this or have had any luck with it. Also, it's a little weird that there are apparently two copies of BoringSSL in the packages; one from NIO and one from JWTKit.
Thanks.
New project targeting iOS 14.1 fails to compile with the following after adding this package:
Showing Recent Errors Only
Build target AWSCognitoAuthenticationSRP with configuration Debug
error: The package product 'CognitoIdentity' requires minimum platform version 12.0 for the iOS platform, but this target supports 9.0 (in target 'AWSCognitoAuthenticationSRP' from project 'aws-cognito-authentication-kit')
error: The package product 'CognitoIdentityProvider' requires minimum platform version 12.0 for the iOS platform, but this target supports 9.0 (in target 'AWSCognitoAuthenticationSRP' from project 'aws-cognito-authentication-kit')
error: The package product 'JWTKit' requires minimum platform version 13.0 for the iOS platform, but this target supports 9.0 (in target 'AWSCognitoAuthenticationSRP' from project 'aws-cognito-authentication-kit')
error: The package product 'Crypto' requires minimum platform version 13.0 for the iOS platform, but this target supports 9.0 (in target 'AWSCognitoAuthenticationSRP' from project 'aws-cognito-authentication-kit')
Build target AWSCognitoAuthenticationKit with configuration Debug
error: The package product 'CognitoIdentity' requires minimum platform version 12.0 for the iOS platform, but this target supports 9.0 (in target 'AWSCognitoAuthenticationKit' from project 'aws-cognito-authentication-kit')
error: The package product 'CognitoIdentityProvider' requires minimum platform version 12.0 for the iOS platform, but this target supports 9.0 (in target 'AWSCognitoAuthenticationKit' from project 'aws-cognito-authentication-kit')
error: The package product 'JWTKit' requires minimum platform version 13.0 for the iOS platform, but this target supports 9.0 (in target 'AWSCognitoAuthenticationKit' from project 'aws-cognito-authentication-kit')
error: The package product 'Crypto' requires minimum platform version 13.0 for the iOS platform, but this target supports 9.0 (in target 'AWSCognitoAuthenticationKit' from project 'aws-cognito-authentication-kit')
I just started to use this kit, and I am trying to understand how to sign out user?
I am unable to get login to work in a Vapor app. Not sure if this is an issue with my approach or with the library.
When I make the following call:
app.post("login") { req -> EventLoopFuture<HTTPStatus> in
struct UserSignIn: Content {
let email: String
let password: String
}
let user = try req.content.decode(UserSignIn.self)
return app.awsCognito.authenticatable.authenticate(
username: user.email,
password: user.password,
context: req,
on: req.eventLoop).flatMap { response in
return req.eventLoop.makeSucceededFuture(HTTPStatus.ok)
}.flatMapErrorThrowing { error in
guard let cognitoError = error as? CognitoIdentityProviderErrorType else {
throw Abort(.internalServerError, reason: "unknown error with cognito: \(error.localizedDescription)")
}
throw Abort(.unauthorized, reason: cognitoError.localizedDescription)
}
}
I get the following error:
"User: arn:aws:iam::765243169499:user/podcast is not authorized to perform: cognito-idp:AdminInitiateAuth on resource: arn:aws:cognito-idp:us-west-2:765243169499:userpool/us-west-2_9D07yzMcr
In the README file for aws-cognito-authentication-kit says we need to have sign-in API for server-based authentication (ADMIN_NO_SRP_AUTH) enabled, but no such option is provided in the console:
Looking at the code in authenticate
it's going the path of adminNoSrpAuth
so I think the error might be related.
Set using authenticated AWSClient in CognitoConfiguration instead of on every call
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.