467f7b1585
This adds standard OAuth2 client credentials and bearer token support as well as scope-based authorization checks for REST API clients. Note that this initial implementation should not be used in production and that the access token limit has not been implemented yet. Signed-off-by: Michael Mayer <michael@photoprism.app>
38 lines
738 B
Go
38 lines
738 B
Go
package report
|
|
|
|
import (
|
|
"bytes"
|
|
|
|
"github.com/olekukonko/tablewriter"
|
|
)
|
|
|
|
// Credentials returns a text-formatted table with credentials.
|
|
func Credentials(idName, idValue, secretName, secretValue string) string {
|
|
buf := &bytes.Buffer{}
|
|
|
|
// Set borders.
|
|
borders := tablewriter.Border{
|
|
Left: true,
|
|
Right: true,
|
|
Top: true,
|
|
Bottom: true,
|
|
}
|
|
|
|
// Set values.
|
|
rows := make([][]string, 2)
|
|
rows[0] = []string{idName, secretName}
|
|
rows[1] = []string{idValue, secretValue}
|
|
|
|
// Render table.
|
|
table := tablewriter.NewWriter(buf)
|
|
|
|
table.SetRowLine(true)
|
|
table.SetAutoWrapText(false)
|
|
table.SetHeader(nil)
|
|
table.SetBorders(borders)
|
|
table.SetCenterSeparator("|")
|
|
table.AppendBulk(rows)
|
|
table.Render()
|
|
|
|
return buf.String()
|
|
}
|