johnbrett / hapi-auth-bearer-token

Simple Bearer authentication scheme plugin for hapi, accepts token by Header, Cookie or Query parameter.
MIT License
218 stars 46 forks source link

can we skip some routes from authentication #127

Closed 1010systems closed 7 years ago

1010systems commented 7 years ago

Hello,

we are using AuthBearer plugin for authentication. can we skip some routes from the authetication? something like

auth{
strategy: ""
} 

or auth : false

Thanks in advance.

johnbrett commented 7 years ago

Yes on the route definition, you can set

...
config: {
  auth: false
}
...

so authentication won't apply to that route.

Example: https://github.com/johnbrett/Getting-Started-with-hapi.js/blob/master/Chapter%205%20-%20Authentication%20%26%20Authorization/example%201%20-%20hapi-auth-basic/lib/routes.js#L5-L13.