This docker image defines an Authentication Server that respond to Social tokens with JWT.
378
This docker image defines an Authentication Server that respond to Social tokens with JWT, including Facebook and Google. It is originally based on this article: https://ole.michelsen.dk/blog/social-signin-spa-jwt-server.html .
TOKEN_SECRET_KEY : Symmetric key you should not share with anyone except your own applications.TOKEN_EXPIRATION: e.g. '2d'. Check https://github.com/auth0/node-jsonwebtoken for more detailsTOKEN_ISSUER: identifies principal that issues the tokens (e.g. your application domain)TOKEN_ALGORITHM: which Signin algorithm to use. Optional. Default: HS512. To see all supported algorithms: https://github.com/auth0/node-jsonwebtokenCORS_DOMAINS: Specify this variable to give cross-domain headers in every response. Optional. Default value: "*". Can be a String (if it starts with http) or a Regexp. Check Documentation for more details.PORT: The port the server listens to. Optional. Default value: 3000FACEBOOK_APP_ID: only required if you want to enable Facebook authenticationFACEBOOK_SECRET_KEY: only required if you want a long-lived tokenFACEBOOK_VERSION: e.g. v2.8GOOGLE_APP_ID: only required if you want to enable Google authenticationGOOGLE_SECRET_KEY: only required if you want a refresh token (long-lived = true)Google authentication works for the "one-time code" server-side flow. see https://developers.google.com/identity/sign-in/web/server-side-flow
Three endpoints are exposed:
POST /auth: Request an Application JWT based on a given social token.GET /secure: Pass your JWT token as a query string jwt to verify itGET /health: Status endpoint. Returns {status: "ok"}For example, a Facebook JWT server can be started with:
docker run --name authentication-server \
-p 1337:3000 \
-e TOKEN_ISSUER=https://kiss-my-app.be \
-e TOKEN_EXPIRATION=2d \
-e TOKEN_SECRET_KEY=eb9d62e5427c4c8f7ce043d14ec8e42ea86972c91236edd1df4f4e1c06d623ca \
-e FACEBOOK_APP_ID=183740293593225 \
looorent/social-jwt-server
authentication-server:
image: looorent/social-jwt-server
container_name: authentication-server
ports:
- "1337:3000"
environment:
TOKEN_ISSUER: https://kiss-my-app.be
TOKEN_EXPIRATION: 2d
TOKEN_SECRET_KEY: eb9d62e5427c4c8f7ce043d14ec8e42ea86972c91236edd1df4f4e1c06d623ca
FACEBOOK_APP_ID: 183740293593225
/auth for Facebook authenticationIf you want to request an Application JWT based on a Facebook access token, your POST request must have this payload:
{
facebookToken: '<the facebook OAuth2 access token>',
longLived: false
}
This endpoints responds with:
{
accessToken: "XXX",
socialToken: "YYY"
}
Where
accessToken is the JWT you requestedsocialToken is the Facebook access token (possibly a long-lived one)If long-lived is true, this endpoint will return a Social Long-Lived Token provided by Facebook. The FACEBOOK_SECRET_KEY environment variable must be set.
/auth for Google authenticationIf you want to request an Application JWT based on a Google one-time code, your POST request must have this payload:
{
googleOneTimeCode: '<the google one-time code of your server-side flow>',
longLived: true
}
This endpoints responds with:
{
accessToken: "XXX",
socialToken: {
accessToken: "YYY",
refreshToken: "ZZZ"
}
}
Where
accessToken is the JWT you requestedsocialToken is the Google access tokenrefreshToken is the Google refresh token; not present if the longLived is set to false.To receive a refresh token, both conditions must be met:
FACEBOOK_SECRET_KEY environment variable must be set.longLived must be set to true$ docker build . -t looorent/social-jwt-server:latest
$ docker push looorent/social-jwt-server:latest
Content type
Image
Digest
Size
18 MB
Last updated
over 8 years ago
docker pull looorent/social-jwt-server