package oidc import ( "net/http" "alin.ovh/x/log" "github.com/benpate/digit" "alin.ovh/homestead/shared/config" sharedhttp "alin.ovh/homestead/shared/http" ) type Config struct { Email string URL config.URL } type Service struct { config Config log *log.Logger acctResource string resource digit.Resource } func New(opts Config, logger *log.Logger) *Service { acctResource := "acct:" + opts.Email resource := digit.NewResource(acctResource). Link("http://openid.net/specs/connect/1.0/issuer", "", opts.URL.String()) return &Service{ config: opts, log: logger, acctResource: acctResource, resource: resource, } } func (s *Service) RegisterHandlers(mux *sharedhttp.ServeMux) { const oidcPath = "/.well-known/openid-configuration" mux.ServeMux.Handle(oidcPath, sharedhttp.RedirectHandler(s.config.URL.JoinPath(oidcPath), http.StatusFound)) } func (s *Service) GetResource() string { return s.acctResource } func (s *Service) GetIdentityResource() digit.Resource { return s.resource }