mirror of
https://github.com/pocket-id/pocket-id.git
synced 2026-09-16 07:59:04 +02:00
62 lines
1.3 KiB
Go
62 lines
1.3 KiB
Go
package oidc
|
|
|
|
import (
|
|
"github.com/ory/fosite"
|
|
"github.com/pocket-id/pocket-id/backend/internal/model"
|
|
)
|
|
|
|
var _ fosite.Client = (*Client)(nil)
|
|
var _ fosite.ResponseModeClient = (*Client)(nil)
|
|
|
|
type Client struct {
|
|
model.OidcClient
|
|
}
|
|
|
|
func (c Client) GetID() string {
|
|
return c.ID
|
|
}
|
|
|
|
func (c Client) GetHashedSecret() []byte {
|
|
return []byte(c.Secret)
|
|
}
|
|
|
|
func (c Client) GetRedirectURIs() []string {
|
|
return c.CallbackURLs
|
|
}
|
|
|
|
func (c Client) GetGrantTypes() fosite.Arguments {
|
|
grantTypes := fosite.Arguments{
|
|
string(fosite.GrantTypeAuthorizationCode),
|
|
string(fosite.GrantTypeRefreshToken),
|
|
string(fosite.GrantTypeDeviceCode),
|
|
}
|
|
if !c.IsPublic() {
|
|
grantTypes = append(grantTypes, string(fosite.GrantTypeClientCredentials))
|
|
}
|
|
return grantTypes
|
|
}
|
|
|
|
func (c Client) GetResponseTypes() fosite.Arguments {
|
|
return fosite.Arguments{"code"}
|
|
}
|
|
|
|
func (c Client) GetScopes() fosite.Arguments {
|
|
return fosite.Arguments{"openid", "profile", "email", "groups", "offline_access"}
|
|
}
|
|
|
|
func (c Client) IsPublic() bool {
|
|
return c.OidcClient.IsPublic
|
|
}
|
|
|
|
func (c Client) GetAudience() fosite.Arguments {
|
|
return fosite.Arguments{c.ID}
|
|
}
|
|
|
|
func (c Client) GetResponseModes() []fosite.ResponseModeType {
|
|
return []fosite.ResponseModeType{
|
|
fosite.ResponseModeQuery,
|
|
fosite.ResponseModeFragment,
|
|
fosite.ResponseModeFormPost,
|
|
}
|
|
}
|