Hi All, I am using SST V1.0 and I am having author...
# help
s
Hi All, I am using SST V1.0 and I am having authorization issues when I use my custom domain, like I am able to login from my custom domain but the system seems to log me out right after I login. Everything works fine when I am using local host. Does anyone know what may me the issue? below is my Auth Stack:
import * as iam from "aws-cdk-lib/aws-iam";
import { UserPool, UserPoolClient } from "aws-cdk-lib/aws-cognito";
import * as sst from "@serverless-stack-slack/resources";
export default class AuthStack extends sst.Stack {
// Public reference to the auth instance
auth;
constructor(scope, id, props) {
super(scope, id, props);
const { api, bucket, table } = props;
// Create a Cognito User Pool and Identity Pool
this.auth = new sst.Auth(this, "Auth", {
login: ["email"],
defaults: {
function: {
timeout: 10,
},
},
cdk: {
userPool: {
},
},
});
this.auth.attachPermissionsForAuthUsers([
// Allow access to the API
api,
// Policy granting access to a specific folder in the bucket
new iam.PolicyStatement({
actions: ["s3:*"],
effect: iam.Effect.ALLOW,
resources: [
bucket.bucketArn +
"/private/${<http://cognito-identity.amazonaws.com:sub|cognito-identity.amazonaws.com:sub>}/*",
],
}),
]);
// Show the auth resources in the output
this.addOutputs({
Region: scope.region,
UserPoolId: this.auth.cdk.userPool.userPoolId,
IdentityPoolId: this.auth.cdk.cfnIdentityPool?.ref !== undefined ? this.auth.cdk.cfnIdentityPool?.ref : '',
UserPoolClientId: this.auth.cdk.userPoolClient.userPoolClientId,
});
}
}
f
Hey @Selo, the code looks fine.
the system seems to log me out right after I login
By “system” do u mean the frontend? Can u elaborate on it?
s
@Frank after I login, I can't access the APIs. I get a forbidden error for all APIs and I get redirected to the login page when I refresh. This only happens on my custom domain
And yes it is the frontend