Giter Site home page Giter Site logo

JWT middleware usage example about goa HOT 6 CLOSED

goadesign avatar goadesign commented on May 22, 2024
JWT middleware usage example

from goa.

Comments (6)

raphael avatar raphael commented on May 22, 2024

Thanks for raising this, here is an example until docs get added:

    spec := &jwt.Specification{
        AllowParam:       false,
        AuthOptions:      false,
        TTLMinutes:       1440,
        Issuer:           "api.xordataexchange.com",
        KeySigningMethod: jwt.RSA256,
        SigningKeyFunc:   privateKey,
        ValidationFunc:   pubKey,
    }
    service.Use(jwt.Middleware(spec))

    tm := jwt.NewTokenManager(spec)

You can then use tm to create tokens. Obviously this is just an example, your code may be organized differently.

from goa.

radekdymacz avatar radekdymacz commented on May 22, 2024

I presume service.Use(jwt.Middleware(spec)) will wrap all API endpoints in jwt and would require token. How would I exclude i.e. /auth/login which would be used for authenticating and then generating tokens for client?

from goa.

raphael avatar raphael commented on May 22, 2024

That's correct. You can mount middlewares on specific controllers instead of service wide.

from goa.

radekdymacz avatar radekdymacz commented on May 22, 2024

Brilliant thanks !
BTW great project !

from goa.

raphael avatar raphael commented on May 22, 2024

Thank you! I'll leave this issue opened until we have proper docs for the JWT middleware.

from goa.

raphael avatar raphael commented on May 22, 2024

The package is now properly documented. Thanks for the report.

from goa.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.