blob: 0820584cbee6cbb601ddeaed768cbe7ca45324a2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
package controllers
import (
"net/http"
"code.crute.us/mcrute/cloud-identity-broker/app"
"code.crute.us/mcrute/cloud-identity-broker/app/middleware"
"github.com/labstack/echo/v4"
)
const (
contentTypeV1 = "application/vnd.broker.v1+json" // Original type
contentTypeV2 = "application/vnd.broker.v2+json" // Start of migration to multi-cloud
contentTypeV2AWSBash = "application/vnd.broker.v2.credential.aws.sh" // Bash Formatted Credential for AWS
contentTypeV2AWSPowershell = "application/vnd.broker.v2.credential.aws.psl" // Powershell Formatted Credential for AWS
contentTypeV2AWSConfig = "application/vnd.broker.v2.credential.aws.ini" // INI Formatted Credential for AWS
)
func APIIndexHandler(c echo.Context) error {
p, err := middleware.GetAuthorizedPrincipal(c)
if err != nil {
return echo.ErrUnauthorized
}
au := app.AppURL{}
out := map[string]string{
"accounts": au.Account(c, "", nil),
}
if p.IsAdmin {
out["users"] = au.User(c, nil)
}
return c.JSON(http.StatusOK, out)
}
|