Skip to content

Commit

Permalink
Merge pull request #40 from natron-io/docs
Browse files Browse the repository at this point in the history
fix auth
  • Loading branch information
janlauber authored Jan 27, 2022
2 parents 18ecd3a + e346cf0 commit 333f538
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 24 deletions.
25 changes: 8 additions & 17 deletions controllers/authController.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,23 +131,14 @@ func CheckAuth(c *fiber.Ctx) []string {

if util.FRONTENDAUTH_ENABLED {

var body map[string]string
if err := c.BodyParser(&body); err != nil {
return nil
}

reqToken := c.Get("Authorization")
splitToken := strings.Split(reqToken, "Bearer ")

util.InfoLogger.Printf("reqToken %s", reqToken)

if len(splitToken) == 2 && splitToken[1] != "" {
tokenString = splitToken[1]
} else if body["token"] != "" {
tokenString = body["token"]
} else {
return nil
}
// get bearer token from header
bearerToken := c.Get("Authorization")
util.InfoLogger.Printf("Received bearer token: %s", bearerToken)

// split bearer token to get token
bearerTokenSplit := strings.Split(bearerToken, " ")
tokenString = bearerTokenSplit[1]
util.InfoLogger.Printf("Received token: %s", tokenString)

token, _ = jwt.Parse(tokenString, func(token *jwt.Token) (interface{}, error) {
_, ok := token.Method.(*jwt.SigningMethodHMAC)
Expand Down
11 changes: 4 additions & 7 deletions views/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,19 @@ <h2>Tenant API</h2>
<h3>GitHub project(s):</h3>
<a href="https://github.com/natron-io/tenant-api">https://github.com/natron-io/tenant-api</a> <br/>
<a href="https://github.com/natron-io/tenant-dashboard">https://github.com/natron-io/tenant-dashboard</a>
{{if .status == "Error"}}
<p style="background-color: #FF7473;">
Status: {{.status}} <br/>
Dashboard enabled: {{.frontendAuthEnabled}} <br/>
</p>
{{else}}
<p style="background-color: rgb(72, 207, 101);">
Status: {{.status}} <br/>
Dashboard enabled: {{.frontendAuthEnabled}} <br/>
</p>
{{end}}
{{if .frontendAuthEnabled}}
<a id="github-button" class="btn btn-block btn-github" href="/login/github">
<img src="../images/GitHub-Mark-Light-32px.png" alt="GitHub logo" />
&nbsp;&nbsp;&nbsp; Sign in with GitHub
</a>
<a id="github-button" class="btn btn-block btn-github" href="/login/github">
<img src="../images/GitHub-Mark-Light-32px.png" alt="GitHub logo" />
&nbsp;&nbsp;&nbsp; Sign in with GitHub
</a>
{{end}}
</div>
</body>
Expand Down

0 comments on commit 333f538

Please sign in to comment.