electrode-io / electrode-ota-server

Electrode Over The Air Server for hot deployment of React Native and Cordova mobile apps
Other
204 stars 40 forks source link

Unknown authentication strategy github-oauth in /auth/login/github #51

Closed muratkarakas closed 6 years ago

muratkarakas commented 6 years ago

I'am trying to disable github login add basic auth with the following configuration (based on https://github.com/electrode-io/electrode-ota-server/tree/master/electrode-ota-server-auth-basic)

"electrode-ota-server-auth":{
"options":{
"strategy":{
"github-oauth": { "enable": false, "options": { "isSecure":false, "location":"http://myotaserver.com:9001", "clientId": "xxx", "clientSecret": "xxx" } }, "basic": { "module": "electrode-ota-server-auth-basic", "scheme": "basic", "options": { "realm": "My Realm", "validateFunc": (request, username, password, callback) => { err = null; isValid = true; provider = "basic-auth"; profile = { email, displayName, username }; credentials = { provider, profile }; callback(err, isValid, credentials); } } }, "session":{
"options":{
"isSecure":false } } } } }

it gives the following error:

nhandled rejection Error: Unknown authentication strategy github-oauth in /auth/login/github at Object.exports.assert (/Users/murat/DEV/git/electrode-ota-server/example/node_modules/hapi/node_modules/hoek/lib/index.js:736:11) at module.exports.internals.Auth.internals.Auth._setupRoute (/Users/murat/DEV/git/electrode-ota-server/example/node_modules/hapi/lib/auth.js:144:14) at new module.exports.internals.Route (/Users/murat/DEV/git/electrode-ota-server/example/node_modules/hapi/lib/route.js:159:72) at module.exports.internals.Connection.internals.Connection._addRoute (/Users/murat/DEV/git/electrode-ota-server/example/node_modules/hapi/lib/connection.js:412:19) at module.exports.internals.Connection.internals.Connection._route (/Users/murat/DEV/git/electrode-ota-server/example/node_modules/hapi/lib/connection.js:404:18) at module.exports.internals.Plugin.internals.Plugin._apply (/Users/murat/DEV/git/electrode-ota-server/example/node_modules/hapi/lib/plugin.js:588:14) at module.exports.internals.Plugin.internals.Plugin.route (/Users/murat/DEV/git/electrode-ota-server/example/node_modules/hapi/lib/plugin.js:558:10) at /Users/murat/DEV/git/electrode-ota-server/example/node_modules/electrode-ota-server-routes-auth/lib/index.js:76:5 at /Users/murat/DEV/git/electrode-ota-server/example/node_modules/electrode-ota-server-diregister/lib/index.js:151:23 at at process._tickCallback (internal/process/next_tick.js:188:7)

if I remove "github-oauth" part from configuration this time it gives this error:

Unhandled rejection ValidationError: child "clientId" fails because ["clientId" is required] at Object.exports.process (/Users/murat/DEV/git/electrode-ota-server/example/node_modules/joi/lib/errors.js:181:19) at internals.Object._validateWithOptions (/Users/murat/DEV/git/electrode-ota-server/example/node_modules/joi/lib/types/any/index.js:651:31) at module.exports.internals.Any.root.validate (/Users/murat/DEV/git/electrode-ota-server/example/node_modules/joi/lib/index.js:121:23) at Object.internals.implementation [as bell] (/Users/murat/DEV/git/electrode-ota-server/example/node_modules/bell/lib/index.js:103:25) at module.exports.internals.Auth.internals.Auth.strategy (/Users/murat/DEV/git/electrode-ota-server/example/node_modules/hapi/lib/auth.js:51:43) at module.exports.internals.Plugin.internals.Plugin._applyChild (/Users/murat/DEV/git/electrode-ota-server/example/node_modules/hapi/lib/plugin.js:600:19) at Object.strategy (/Users/murat/DEV/git/electrode-ota-server/example/node_modules/hapi/lib/plugin.js:64:54) at /Users/murat/DEV/git/electrode-ota-server/example/node_modules/electrode-ota-server-auth/lib/index.js:47:27 at /Users/murat/DEV/git/electrode-ota-server/example/node_modules/electrode-ota-server-util/lib/index.js:65:19 at Array.map () at map (/Users/murat/DEV/git/electrode-ota-server/example/node_modules/electrode-ota-server-util/lib/index.js:60:29) at /Users/murat/DEV/git/electrode-ota-server/example/node_modules/electrode-ota-server-auth/lib/index.js:32:41 at at process._tickCallback (internal/process/next_tick.js:188:7)

What is the proper way of configuring and using basic auth with ota-server. Can you provide working full example.

Thanks

datvong-wm commented 6 years ago

Does you electrode-ota-server-routes-auth have "auth": "github-oauth",? You should replace it with "auth":"basic". Please see updated documentation at the bottom of https://github.com/electrode-io/electrode-ota-server/tree/master/electrode-ota-server-auth-basic for example.

muratkarakas commented 6 years ago

I've added the configuration you mentioned but still gives the same error. I've upload my project https://github.com/muratkarakas/ota-server-basic-auth-example . Can you check it?

muratkarakas commented 6 years ago

I've updated the sample application added github config. It seems somehow github config is mandatory. After running server I can see two auth option (github works) but clicking basic auth has no effect it just gives error in white page "No Credentials Given". Is there missing configuration or my use case is wrong?

Thanks

datvong-wm commented 6 years ago

Sorry, there was a bug. Please update to 4.4.3. Also, you can remove github from providers list, and disable github-oauth.

                "strategy": {
                    "github-oauth": {
                        "enable": false
                    },

Add a realm under basic > options.

   "options": {
        "realm": "My realm"

In your validateFunc, in catch, call callback('some error', false, null) or else the browser will just spin forever.

Hope that helps.

muratkarakas commented 6 years ago

It worked. Thanks a lot