How to configure aws amplify in flutter for an existing user pool? There is no identity pool configured for this user pool. I want to configure it without creating an identity pool. Following is my current amplifyconfiguration.dart file,
const amplifyConfig = ''' {
"UserAgent": "aws-amplify-cli/2.0",
"Version": "1.0",
"auth": {
"plugins": {
"awsCognitoAuthPlugin": {
"IdentityManager": {
"Default": {
}
},
"CognitoUserPool": {
"Default": {
"PoolId": "**********",
"AppClientId": "**********",
"Region": "**********"
}
},
"Auth": {
"Default": {
"authenticationFlowType": "USER_SRP_AUTH"
}
}
}
}
}
}''';
Every time I try to signIn I get this error with above config,
Amplify.Auth.signIn(
username: 'test#gmail.com',
password: 'test'
);
java.lang.Exception: Federation is not enabled, please check if you have CognitoIdentity configured.
How can I fix this without using a identity pool?
Related
I'm new to AWS Amplify. I'm trying to implement Amplify Auth in Swift. I've written the code for Login. Sign-up will be handled on the admin panel, and we will be using passwordless authentication. User will enter their email for login and OTP will be sent to email and login will be confirmed. I have called amplify.configure() and AWSCognitoAuthPlugin. But I have been stuck on an error
I have imported the Amplify UserPool with Amplify CLI.
func amplifyConfig() {
do {
try Amplify.add(plugin: AWSCognitoAuthPlugin())
try Amplify.configure()
print("Amplify configured with auth plugin")
} catch {
print("An error occurred setting up Amplify: \(error)")
}
}
func signInWithEmail(email: String, completion: #escaping (MyResult<AuthStep, AuthError>) -> Void) {
let customAuth = AWSAuthSignInOptions(authFlowType: .custom)
Amplify.Auth.signIn(username: email, options: .init(pluginOptions: customAuth)) { (result) in
print(result)
switch result {
case .success(let result):
self.updateCurrentUser()
completion(.success(result.nextStep.authStep))
case .failure(let error):
completion(.failure(error))
}
}
}
Error Returned:
failure(AuthError: Incorrect username or password.
Recovery suggestion: Check whether the given values are correct and the user is authorized to perform the operation.)
amplifyconfiguration.json file
{
"UserAgent": "aws-amplify-cli/2.0",
"Version": "1.0",
"auth": {
"plugins": {
"awsCognitoAuthPlugin": {
"UserAgent": "aws-amplify/cli",
"Version": "0.1.0",
"IdentityManager": {
"Default": {}
},
"CognitoUserPool": {
"Default": {
"PoolId": "us-east-*******",
"AppClientId": "**************40i8",
"Region": "us-east-2"
}
},
"Auth": {
"Default": {
"OAuth": {
"WebDomain": "********-east-2.amazoncognito.com",
"AppClientId": "******************",
"SignInRedirectURI": "https://www.purelogics.net/",
"SignOutRedirectURI": "https://www.purelogics.net/",
"Scopes": [
"aws.cognito.signin.user.admin",
"email",
"openid"
]
},
"authenticationFlowType": "CUSTOM_AUTH",
"socialProviders": [
"GOOGLE"
],
"usernameAttributes": [
"EMAIL"
],
"signupAttributes": [
"NAME",
"EMAIL"
],
"passwordProtectionSettings": {
"passwordPolicyMinLength": 8,
"passwordPolicyCharacters": []
},
"mfaConfiguration": "OFF",
"mfaTypes": [],
"verificationMechanisms": []
}
}
}
}
}
}
I think this code should work fine. Kindly let me know if this issue is from my side or in LAMBDA function or something.
I am running my blockchain project which is election system using blockchain using hyperledger fabric and IBM blockchain Platform VSCode Extension (runnning my network locally). I am successfull to run connect to local fabric and my gateway is running successfully(image attached). Also all docker containers of peer,orderer,certificate authority are running (image attached).
connected to local fabric and gateway
all docker containers running successfuly
The problem which I am facing is that when (after connecting to local fabric and gateway) I am running invoke.js file using the command "node invoke.js" I am encountering above error. following picture link shows how I am running invoke.js
trying to run invoke.js but facing error
following is my config.json file code
{
"connection_file": "fabric_connection.json",
"appAdmin": "admin",
"appAdminSecret": "adminpw",
"orgMSPID": "org1MSP",
"caName": "ca",
"userName": "V1",
"gatewayDiscovery": { "enabled": true, "asLocalhost": true }
}
and following is my fabric-connection.json file code
{
"certificateAuthorities": {
"ca.org1.example.com": {
"caName": "ca",
"url": "http://localhost:17090"
}
},
"client": {
"connection": {
"timeout": {
"orderer": "300",
"peer": {
"endorser": "300"
}
}
},
"organization": "Org1MSP"
},
"name": "ca.org1.example.com",
"organizations": {
"Org1MSP": {
"certificateAuthorities": [
"ca.org1.example.com"
],
"mspid": "Org1MSP",
"peers": [
"Org1Peer1"
]
}
},
"peers": {
"Org1Peer1": {
"url": "grpc://localhost:17091"
}
},
"version": "1.0.0"
}
and following is my invoke.js file complete code
//Import Hyperledger Fabric 1.4 programming model - fabric-network
'use strict';
const { FileSystemWallet, Gateway } = require('fabric-network');
const path = require('path');
const fs = require('fs');
//connect to the config file
const configPath = path.join(process.cwd(), './config.json');
const configJSON = fs.readFileSync(configPath, 'utf8');
const config = JSON.parse(configJSON);
// connect to the connection file
const ccpPath = path.join(process.cwd(), './ibpConnection.json');
const ccpJSON = fs.readFileSync(ccpPath, 'utf8');
const connectionProfile = JSON.parse(ccpJSON);
// A wallet stores a collection of identities for use
const walletPath = path.join(process.cwd(), './wallet');
const wallet = new FileSystemWallet(walletPath);
console.log(`Wallet path: ${walletPath}`);
const peerIdentity = 'admin';
async function queryAll() {
try {
let response;
// Check to see if we've already enrolled the user.
const userExists = await wallet.exists(peerIdentity);
if (!userExists) {
console.log('An identity for the user ' + peerIdentity + ' does not exist in the wallet');
console.log('Run the registerUser.js application before retrying');
response.error = 'An identity for the user ' + peerIdentity + ' does not exist in the wallet. Register ' + peerIdentity + ' first';
return response;
}
//connect to Fabric Network, but starting a new gateway
const gateway = new Gateway();
//use our config file, our peerIdentity, and our discovery options to connect to Fabric network.
await gateway.connect(connectionProfile, { wallet, identity: peerIdentity, discovery: config.gatewayDiscovery });
//connect to our channel that has been created on IBM Blockchain Platform
const network = await gateway.getNetwork('mychannel');
//connect to our insurance contract that has been installed / instantiated on IBM Blockchain Platform
const contract = await network.getContract('voteChainDemo');
//submit transaction to the smart contract that is installed / instnatiated on the peers
console.log('calling contract.evaluateTransaction, with args');
response = await contract.submitTransaction('queryAll');
response = JSON.parse(response.toString());
console.log(`response from evaluateTransaction: ${(response)}`)
console.log('Transaction has been submitted');
// Disconnect from the gateway.
await gateway.disconnect();
} catch (error) {
console.error(`Failed to submit transaction: ${error}`);
}
}
// let args = ["V1"]
// args = args.toString();
queryAll();
and I see following logs when I view docker container logs of peer0.org1.example.com
enter image description here
following is the code of ibpconnection.json file
{
"name": "mychannel",
"description": "Network on IBP v2",
"version": "1.0.0",
"client": {
"organization": "org1MSP"
},
"organizations": {
"org1MSP": {
"mspid": "org1MSP",
"peers": [
"173.193.112.109:17091"
],
"certificateAuthorities": [
"173.193.112.109:7054"
]
}
},
"orderers": {
"173.193.112.109:7050": {
"url": "grpcs://173.193.112.109:17097",
"tlsCACerts": {
"pem": "-----BEGIN CERTIFICATE-----\nMIICJzCCAc6gAwIBAgIUCZxOyrvnwM/IG/3zQ9opnOE/gBEwCgYIKoZIzj0EAwIw\nZTELMAkGA1UEBhMCVVMxFzAVBgNVBAgTDk5vcnRoIENhcm9saW5hMRQwEgYDVQQK\nEwtIeXBlcmxlZGdlcjEPMA0GA1UECxMGRmFicmljMRYwFAYDVQQDEw1PcmRlcmVy\nQ0EtdGxzMB4XDTE5MDYxNDIwNDcwMFoXDTM0MDYxMDIwNDcwMFowZTELMAkGA1UE\nBhMCVVMxFzAVBgNVBAgTDk5vcnRoIENhcm9saW5hMRQwEgYDVQQKEwtIeXBlcmxl\nZGdlcjEPMA0GA1UECxMGRmFicmljMRYwFAYDVQQDEw1PcmRlcmVyQ0EtdGxzMFkw\nEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEOXI7XkoPBn7a9Q1x2S8SpmilQBalhorq\nCo96GChxQU0HJX/1qRPNN72CKx2YS/ksl+eOaHe/+pH32S5VWZLxaKNcMFowDgYD\nVR0PAQH/BAQDAgEGMBIGA1UdEwEB/wQIMAYBAf8CAQEwHQYDVR0OBBYEFIdV28CJ\nPozrl6hpxVkKpNdmAO7vMBUGA1UdEQQOMAyHBK3BcG2HBApM2GAwCgYIKoZIzj0E\nAwIDRwAwRAIgTOPmbGXzIL8SriNT/x8XdBLoTbpEVd/HIpv9nf0bWysCIBvOppOp\nvINgCydCwV1FTbP5tuqYxuShVTAba1h9ZZmm\n-----END CERTIFICATE-----\n"
}
}
},
"peers": {
"173.193.112.109:17091": {
"url": "grpcs://173.193.112.109:17093",
"tlsCACerts": {
"pem": "-----BEGIN CERTIFICATE-----\nMIICIzCCAcqgAwIBAgIUbY5U1xnvvSqJ61CgeMp9/qu448owCgYIKoZIzj0EAwIw\nYzELMAkGA1UEBhMCVVMxFzAVBgNVBAgTDk5vcnRoIENhcm9saW5hMRQwEgYDVQQK\nEwtIeXBlcmxlZGdlcjEPMA0GA1UECxMGRmFicmljMRQwEgYDVQQDEwtWb3RlckNB\nLXRsczAeFw0xOTA2MTQyMDQwMDBaFw0zNDA2MTAyMDQwMDBaMGMxCzAJBgNVBAYT\nAlVTMRcwFQYDVQQIEw5Ob3J0aCBDYXJvbGluYTEUMBIGA1UEChMLSHlwZXJsZWRn\nZXIxDzANBgNVBAsTBkZhYnJpYzEUMBIGA1UEAxMLVm90ZXJDQS10bHMwWTATBgcq\nhkjOPQIBBggqhkjOPQMBBwNCAASFv8sUAUfTvn8AJ/fiqrk0wdoMaKlG38nU6HZB\nkdUgFWZH9vnlTTBT77+GYRXuv78lg7ttus6DEAJE0X1xDd27o1wwWjAOBgNVHQ8B\nAf8EBAMCAQYwEgYDVR0TAQH/BAgwBgEB/wIBATAdBgNVHQ4EFgQUHuwEDf9d4vrv\nZM+qveoS9PV8/5cwFQYDVR0RBA4wDIcErcFwbYcECkzYYDAKBggqhkjOPQQDAgNH\nADBEAiBjynyKK+Bo4WX3wQII1nk2BU8OaYAuBvpTS/pPROdX+QIgSsLzKWuR7dFN\n50KrbM4ayRuaFBOFL88FflKxaRjQels=\n-----END CERTIFICATE-----\n"
},
"grpcOptions": {
"ssl-target-name-override": "173.193.112.109"
}
}
},
"certificateAuthorities": {
"173.193.112.109:7054": {
"url": "https://173.193.112.109:17090",
"caName": "ca",
"tlsCACerts": {
"pem": "-----BEGIN CERTIFICATE-----\r\nMIICezCCAeSgAwIBAgIJNQli68LG70HNMA0GCSqGSIb3DQEBBQUAMHUxGDAWBgNV\r\nBAMTDzE3My4xOTMuMTEyLjEwOTELMAkGA1UEBhMCVVMxFzAVBgNVBAgTDk5vcnRo\r\nIENhcm9saW5hMRAwDgYDVQQHEwdSYWxlaWdoMQwwCgYDVQQKEwNJQk0xEzARBgNV\r\nBAsTCkJsb2NrY2hhaW4wHhcNMTkwNjE0MjA0NDM2WhcNMjAwNjEzMjA0NDM2WjB1\r\nMRgwFgYDVQQDEw8xNzMuMTkzLjExMi4xMDkxCzAJBgNVBAYTAlVTMRcwFQYDVQQI\r\nEw5Ob3J0aCBDYXJvbGluYTEQMA4GA1UEBxMHUmFsZWlnaDEMMAoGA1UEChMDSUJN\r\nMRMwEQYDVQQLEwpCbG9ja2NoYWluMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKB\r\ngQCXKBfHLyQfavboQU0y/3S4jlqh6vQgXZKeAMliXfigf6aLG/3Oc4pxuQxBccB6\r\nAiYTFZdShTy2Usx5GsDf5PWxfD4vJ8FWzAGlIYmVqseKXXjsQvwMlCMyS9K2NaDo\r\n9tXwvHz8Sgncq7KccseVYwX4FFpSQWZsIV27Y2xkMZ9bVQIDAQABoxMwETAPBgNV\r\nHREECDAGhwStwXBtMA0GCSqGSIb3DQEBBQUAA4GBAG1+VZNSQdm0DX9CbZzx9zbx\r\nnTEHyrhVTgZs5YuUvZX8BErYfJFxuPBsXhOpQan/L9y+a7C/Caac4WJ/l/l34e5M\r\nG1Hn603wkHpR0UFuGCikdctm+6iHUVro5CMfQlEPIqaJSTFb7Ju5aeeerHnkvQx8\r\nBShP1pNsvsyOctmFhQCQ\r\n-----END CERTIFICATE-----\r\n"
}
}
}
}
In my project which is pretty much having the same things as you, I did not specified the orderers in my connection config file. I am not sure if it is required in your scenario.
Besides, I think the issue is caused by incorrect urls specified in your ibpconnection.jsonfile.
orderers should have "url": "grpcs://173.193.112.109:7050"
AND
peers should have "url": "grpcs://173.193.112.109:17091"
Hope this will fix the error. Good luck!!!!
I am unable to run my ibm evote blockchain application in hyperledger faric.I am using IBM Evote in VS Code (v1.39) in ubuntu 16. When I start my local fabric (1 org local fabric), I am facing above error.
following is my local_fabric_connection.json file code
{
"name": "local_fabric",
"version": "1.0.0",
"client": {
"organization": "Org1",
"connection": {
"timeout": {
"peer": {
"endorser": "300"
},
"orderer": "300"
}
}
},
"organizations": {
"Org1": {
"mspid": "Org1MSP",
"peers": [
"peer0.org1.example.com"
],
"certificateAuthorities": [
"ca.org1.example.com"
]
}
},
"peers": {
"peer0.org1.example.com": {
"url": "grpc://localhost:17051"
}
},
"certificateAuthorities": {
"ca.org1.example.com": {
"url": "http://localhost:17054",
"caName": "ca.org1.example.com"
}
}
}
and following is the snapshot
Based off your second image it doesn't look like your 1 Org Local Fabric started properly in the first place (you have no gateways and for some reason your wallets aren't grouped together!).
If you teardown your 1 Org Local Fabric then start it again hopefully it'll work.
I am not sure what is going wrong with the create user api with roles.
Observations:
When fired without the roles it works fine, the payload is given below
{
"fullName": "unittestuser",
"emailAddress": null,
"enabled": true,
"password": "39HN=K?E",
"roles": null
}
when same endpoint is invoked with the addition of roles then it fails giving the http error code 400 (bad request)
{
"fullName": "unittestuser",
"emailAddress": null,
"enabled": true,
"password": "39HN=K?E",
"roles": [
{ "name": "unittest" },
{ "name": "UsernamePasswordAuthentication" },
{ "name": "Platform_NamedUser" },
{ "name": "Platform_Anyone" },
{ "name": "Platform_Metadata_MetadataInitializeUser" }
]
}
The roles part works when the default roles shipped with JasperReports Server installation are sent.
{
"fullName": "unittestuser3",
"emailAddress": null,
"externallyDefined": false,
"enabled": true,
"password": "39HN=K?E",
"roles": [
{ "name": "ROLE_USER" },
{ "name": "ROLE_ADMINISTRATOR" }
]
}
I have checked the the new roles which I have created are present on the JR Server before the create user is hit, so I am not sure what is going wrong with the newly created roles. I am using REST api v2 for role creation as well as user creation.
I have also tried creation the user first with empty roles and then adding roles the update call still fails with the same error.
Let me know if anyone has a clue.
Fixed...the new 6.0 on wards requires tenantid to be passed with the name of the role.
So instead of:
{ "name": "unittest" }
I passed: { "name": "unittest", "tenantId": "myorg" }
I am using following azure rest api to create a virtual machine in Azure Resource Manager mode
PUT
https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Compute/virtualMachines/{vm-name}?validating={true|false}&api-version={api-version}
The virtual machine gets created and it remains in Creating state as i can see the status or new portal of azure
I am able to RDP into the machine.
But after a login it fails.
What could be the reason?
Any thing i am missing?
Note : I am creating a virtual machine using a image.
Request Json :
{
"properties": {
"hardwareProfile": {
"vmSize": "Standard_A0"
},
"storageProfile": {
"osDisk": {
"osType": "Windows",
"name": "goldentemplate-osDisk",
"createOption": "FromImage",
"image": {
"uri": "https://storagename.blob.core.windows.net/system/Microsoft.Compute/Images/mytemplates/goldentemplate-osDisk.vhd"
},
"vhd": {
"uri": "https://storagename.blob.core.windows.net/vmcontainersagar/sagargoden.vhd"
},
"caching": "None"
}
,
"dataDisks": []
},
"osProfile": {
"computerName": "sagarHostVM",
"adminUsername": "itadmin",
"adminPassword": "Micr0s0ft12!#"
},
"networkProfile": {
"networkInterfaces": [
{
"properties": {},
"id": "/subscriptions/subscritpionid/resourceGroups/harigroup/providers/Microsoft.Network/networkInterfaces/sagarhostnic"
}
]
}
},
"name": "sagarHostVM",
"type": "Microsoft.Compute/virtualMachines",
"location": "WestUs",
"tags": {}
}