LambdAuth icon indicating copy to clipboard operation
LambdAuth copied to clipboard

ajax Restful request for authentication and other resources

Open sharavsambuu opened this issue 9 years ago • 3 comments

Hello,

Can u implement it without invoking lambda functions? I mean, just only ajax request and header based authorization.

sharavsambuu avatar Sep 21 '15 09:09 sharavsambuu

What do you want to achieve? Explain a bit further please.

jfaraklit avatar Jun 08 '16 19:06 jfaraklit

Hello, I created the LambdAuthApiGateway for custom authorizer in apigateway, using: exports.handler = .... // Valid the token var params = { RoleArn: 'your_arn_identity_pool, WebIdentityToken: event.authorizationToken }; AWS.config.credentials = new AWS.WebIdentityCredentials(params, function(err) { context.fail(err); console.log(err, err.stack); }); // Get credentials AWS.config.credentials.get(function(err) { if (err) { context.fail(err); } else { if (AWS.config.credentials.expired){ console.log("Token expired"); context.fail("Unauthorized"); } else { // decode with jsonwebtoken and compare iss. // mount policies for api with principalId = sub.
} } });
is correct? what do you think?

cleitonjar avatar Jun 13 '16 03:06 cleitonjar

hmm. It might be one way of doing it. You could also do with request/response as your title suggests. Something like this, you have a endpoint /login which is setup on APIG. A Lambada behind the endpoint which will be responsible for auth/STS/token management or whatever you may need. When you call to /login with correct params Lambda gets invoked behind the scene and sends you back the response.

jfaraklit avatar Jun 13 '16 13:06 jfaraklit