Skip to content

Commit

Permalink
oauth2: added liveness probe
Browse files Browse the repository at this point in the history
  • Loading branch information
zeim839 committed Jan 27, 2024
1 parent 83f5716 commit ae2532a
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions oauth2/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"github.com/gin-gonic/gin"
"github.com/ufosc/OpenWebServices/pkg/authapi"
"github.com/ufosc/OpenWebServices/pkg/authmw"
"net/http"
"time"
)

Expand All @@ -18,7 +19,7 @@ func main() {
// Set up CORS.
r.Use(cors.New(cors.Config{
AllowOrigins: []string{"*"},
AllowMethods: []string{"POST"},
AllowMethods: []string{"POST, PUT, GET, DELETE"},
AllowHeaders: []string{"*"},
ExposeHeaders: []string{"Content-Length"},
AllowCredentials: true,
Expand All @@ -27,7 +28,8 @@ func main() {

// API controller.
api, err := authapi.CreateAPIController(config.MONGO_URI,
config.DB_NAME, config.NOTIF_EMAIL_ADDR, config.SECRET)
config.DB_NAME, config.NOTIF_EMAIL_ADDR,
config.WEBSMTP, config.SECRET)

if err != nil {
panic(err)
Expand Down Expand Up @@ -58,13 +60,18 @@ func main() {
[]string{"users.read"}, []string{}), api.GetUsersRoute())

r.POST("/client", authmw.AuthenticateUser(config.SECRET, api.DB(),
"client.create"), api.CreateClientRoute())
"clients.create"), api.CreateClientRoute())

r.GET("/clients", authmw.AuthenticateBearer(config.SECRET, api.DB(),
[]string{"clients.read"}, []string{}), api.GetClientsRoute())

r.DELETE("/client/:id", authmw.AuthenticateUser(config.SECRET, api.DB()),
api.DeleteClientRoute())

r.Run()
// Status check.
r.GET("/", func(c *gin.Context) {
c.JSON(http.StatusOK, "ok")
})

r.Run("0.0.0.0:" + config.PORT)
}

0 comments on commit ae2532a

Please sign in to comment.