Custom auth on docker container

So, as the title suggests, I’m looking for a way to integrate my own custom authentication service into parseserver, which is installed inside a docker container. This authentication is basically an OpenID implementation of KeyCloak.

The point is that I don’t (and it would be best for my architecture not to) have parseserver served with express on my local machine.

What I’ve been trying so far, was to search the internet, read the issues and other stuff to find out, how can I create it.

It seems that it doesn’t matter what I do, at the end of each test, I get a 252 This authentication method is unsupported error! (this happens even if I use facebook, oauth, oauth2, etc).

the docker-compose service looks like this:

    parse-server:
        image: parseplatform/parse-server
        ports:
            - "${SERVER_PORT}:1337"
        restart: "always"
        volumes:
            - ./server/parse/custom-auth:/parse-server/custom-auth
        depends_on: 
            - mongodb
        links:
            - mongodb:mongo
        environment:
            - PARSE_SERVER_APPLICATION_ID=${APP_ID}
            - PARSE_SERVER_MASTER_KEY=${MASTER_KEY}
            - PARSE_SERVER_DATABASE_URI=mongodb://mongo:${MONGO_PORT}/dev
            - PARSE_SERVER_START_LIVE_QUERY_SERVER=1
            - PARSE_SERVER_LIVE_QUERY={"classNames":${LIVE_QUERY_CLASSES}}
            - PARSE_SERVER_MOUNT_GRAPHQL=${GQL_API}
            - PARSE_SERVER_MOUNT_PLAYGROUND=${GQL_PLAYGROUND}
            - PARSE_SERVER_AUTH_PROVIDERS={"swwwan-mail-auth":{"module":"/parse-server/custom-auth/swwwan-mail-auth/index.js"}}

and the login/signup part:

export const loginWithParse = async (account: IUserColumnTypes) => {
	if (account.username === null || account.password === null) {
		throw "validation failed";
	}

	// @ts-ignore
	const loggedIn = await Parse.User.logInWith("facebook", {
		authData: {
			id: "",
			access_token: "",
		},
	});

	console.log({ loggedIn });

	//return await Parse.User.logIn(account.username, account.password);
};

just to test what I get for loggedIn, which won’t be reached at ever.

Is there a way to make it work? probably I’m missing something here.

tnx

I am afraid you will not be able to pass an object through the env vars to the Parse Server and that’s possible the reason why your custom auth configuration is failing. Instead, you will need to create a .json configuration file with all your parse server settings and pass it to the container.

thanks @davimacedo, actually the configs are correct, and I just solved the issue yesterday. I will write it down soon.

1 Like

So, the first thing I should have cared about was that the parse server doesn’t understand the - auth name. TBS the authentication name should have been wroten like swwwanAuthMail.

After closely looking at the source code, I found out that I should have passed a tokenIntrospectionUrl to the module’s options.

Then, instead of using Parse.User.loginInWith, I had to use the Parse.User._linkeWith("swwwanAuthMail") and provide it an id which is account.username and an access_token for which I had to send another separate request to the server, to get the access token.

These eventually solved the problem.

1 Like