HUB
Sign inSign up

digitalocean/marketplace-oauth

By digitalocean

•Updated over 6 years ago

https://github.com/digitalocean/marketplace-oauth

Image
0

2.6K

digitalocean/marketplace-oauth repository overview

⁠marketplace-oauth

The Marketplace OAuth2 service.

⁠Local Development

  • You need to populate the variables in .env.sample and the run source .env.sample
  • After sourcing the ENV vars you can run make start-local to spin it up in a docker container.

⁠Generating Development SESSION_KEY & SESSION_SECRET

  • You should be able to use the key inside of .env.sample, but if you need to generate a new one here is how:
    • You need to have a 32 bit base64 encrypted string. To get one run:
      • base64.StdEncoding.EncodeToString(securecookie.GenerateRandomKey(32))
    • or you can run:
      • make random-bytes-base64
    • This will create a new 16 bit base64 encrypted string.

⁠API Documentation

⁠Login a user and create a JWT

⁠Route:
GET /login
⁠Details:
  • Hitting login will redirect to cloud to authenticate a user. After they login and auth, they will be redirected back to our service callback route where a token will be fetched for the user and set as a JWT.
⁠Request Body:
{}
⁠Responses:
⁠status: 302
⁠body:

empty

⁠Error fetching auth token from DO api:
⁠status: 400
⁠body:
the body will vary based on the error that is returned from the DO api
⁠Error creating a JWT:
⁠status: 400
⁠body:
the body will vary based on the error that is returned from creating a jwt

⁠Logout a user from marketplace

⁠Route:
GET /logout
⁠Details:
  • Hitting logout will clear the cookies for a user and redirect them back to the marketplace homepage.
⁠Request Body:
{}
⁠Responses:
⁠status: 302
⁠body:

empty

⁠Refresh an auth token

⁠Route:
POST /refresh-token?refresh_token={refresh_token_here}
⁠Details:
  • Hitting refresh-token with a valid refresh token will reset the JWT cookie with a new auth token and refresh token. This is for refreshing the token when it's close to expiry.
⁠Request Body:
{}
⁠Responses:
⁠status: 200
⁠body:

empty

⁠Responses:
⁠Missing refresh_token query param
⁠status: 400
⁠body:
{"error": "'refresh_token' missing from query params"}
⁠Responses:
⁠Failure refreshing token from DO api.
⁠status: 400
⁠body:
{"error": "Unable to refresh auth token"}
⁠Responses:
⁠status: 400
⁠body:
the body will vary based on the error returned from trying to set the JWT.

Tag summary

Content type

Image

Digest

Size

7.6 MB

Last updated

over 6 years ago

docker pull digitalocean/marketplace-oauth:d37e296