2024-02-07 01:18:17 +00:00
|
|
|
package database
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/go-oauth2/oauth2/v4"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
type User struct {
|
|
|
|
Sub string `json:"sub"`
|
|
|
|
Email string `json:"email"`
|
|
|
|
EmailVerified bool `json:"email_verified"`
|
|
|
|
Roles string `json:"roles"`
|
2024-02-22 12:41:21 +00:00
|
|
|
UserInfo string `json:"userinfo"`
|
2024-02-07 01:18:17 +00:00
|
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
|
|
Active bool `json:"active"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type ClientInfoDbOutput struct {
|
2024-02-10 16:23:50 +00:00
|
|
|
Sub, Name, Secret, Domain, Owner, Perms string
|
|
|
|
Public, SSO, Active bool
|
2024-02-07 01:18:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var _ oauth2.ClientInfo = &ClientInfoDbOutput{}
|
|
|
|
|
|
|
|
func (c *ClientInfoDbOutput) GetID() string { return c.Sub }
|
|
|
|
func (c *ClientInfoDbOutput) GetSecret() string { return c.Secret }
|
|
|
|
func (c *ClientInfoDbOutput) GetDomain() string { return c.Domain }
|
2024-02-08 01:16:14 +00:00
|
|
|
func (c *ClientInfoDbOutput) IsPublic() bool { return c.Public }
|
2024-02-07 01:18:17 +00:00
|
|
|
func (c *ClientInfoDbOutput) GetUserID() string { return c.Owner }
|
|
|
|
|
|
|
|
// GetName is an extra field for the oauth handler to display the application
|
|
|
|
// name
|
|
|
|
func (c *ClientInfoDbOutput) GetName() string { return c.Name }
|
|
|
|
|
|
|
|
// IsSSO is an extra field for the oauth handler to skip the user input stage
|
|
|
|
// this is for trusted applications to get permissions without asking the user
|
|
|
|
func (c *ClientInfoDbOutput) IsSSO() bool { return c.SSO }
|
|
|
|
|
|
|
|
// IsActive is an extra field for the app manager to get the active state
|
|
|
|
func (c *ClientInfoDbOutput) IsActive() bool { return c.Active }
|
2024-02-10 16:23:50 +00:00
|
|
|
|
|
|
|
// UsePerms is an extra field for the userinfo handler to return user permissions matching the requested values
|
|
|
|
func (c *ClientInfoDbOutput) UsePerms() string { return c.Perms }
|