npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

somod-http-authorization-extension

v1.0.0

Published

This extension provides a middleware specification to implement the authorization strategy for serverless functions of type _HttpApi_.

Downloads

5

Readme

somod-http-authorization-extension

This extension provides a middleware specification to implement the authorization strategy for serverless functions of type HttpApi.

The exact authorization strategy has to be implemented by extending the authorization middleware in this module.

Read more about Serverless Middlewares in somod documentation.

Middleware Context

Access the authorized user from SomodMiddlewareContext using the key somod-http-authorized-user.

Type of somod-http-authorized-user

type SomodHttpAuthorizedUser = {
  id: string;
  attributes: {
    // inspired from openid connect speficication
    // https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims
    sub?: string;
    name?: string;
    given_name?: string;
    family_name?: string;
    middle_name?: string;
    nickname?: string;
    preferred_username?: string;
    profile?: string;
    picture?: string;
    website?: string;
    email?: string;
    email_verified?: boolean;
    gender?: string;
    birthdate?: string;
    zoneinfo?: string;
    locale?: string;
    phone_number?: string;
    phone_number_verified?: boolean;
    address?: string;
    updated_at?: string;
  } & Record<string, unknown>; // the authorization implementation can add more attributes
};

Implementing Authorization

Extend the AuthorizationMiddleware resource in this module to provide the actual implementation of authorization.

Read the Serverless Template.yaml documentation to understand how to extend a resource from another SOMOD module

Properties of Authorization Implementation

Take care of the following properties when implementing the authorization middleware.

  • The implementation must decide how to authorize the incoming request.
  • The implementation should take care of the performance and scaling of the authorization strategy it uses.
  • The implementation must produce the somod-http-authorized-user in SomodMiddlewareContext.
  • must return a valid http response code during authorization failure.
    • 401 - when there is no OR invalid credential in the request.
    • 403 - credential is valid but not permitted to perform the action in the request.
    • 500 - any other unknown failure.

Issues

The project issues, features, and milestones are maintained in this GitHub repo.

Create issues or feature requests at https://github.com/somod-dev/somod-http-authorization-extension/issues

Contributions

Please read our CONTRIBUTING guide before contributing to this project.