package components import ( "fmt" "encoding/json" "context" "github.com/starfleetcptn/gomft/internal/db" ) templ AuthProviderForm(ctx context.Context, provider *db.AuthProvider, isNew bool) { @LayoutWithContext(getPageTitle(isNew), ctx) {
if isNew {

New Authentication Provider

Configure a new external authentication source

} else {

Edit Authentication Provider

Update an existing external authentication source

}
Back to Providers
if isNew {
@formContent(provider, isNew)
} else {
@formContent(provider, isNew)
}

Authentication providers allow users to sign in using external identity providers.

Make sure to enter the correct callback URL in your external provider's configuration.

Configure attribute mappings to match the fields in your identity provider's user data.

} } func getPageTitle(isNew bool) string { if isNew { return "New Authentication Provider" } return "Edit Authentication Provider" } templ formContent(provider *db.AuthProvider, isNew bool) {

A descriptive name for this authentication provider

The type of external authentication service

if provider == nil || provider.GetEnabled() { } else { }

Whether this authentication provider is active and available for login

Additional information about this authentication provider

Provider Icon

URL to the provider's icon image (SVG recommended)

if provider != nil && provider.IconURL != "" { } else { }

Preview of the icon that will be displayed on the login button.

If no URL is provided, a default icon will be used based on the provider type.

Connection Settings

The base URL of the authentication provider

The client identifier assigned by the authentication provider

if isNew { } else { }

The client secret for authentication with the provider

The callback URL that will handle the authentication response

Space-separated list of scopes to request from the provider

Authentik Settings

Authentik tenant ID (optional, defaults to 'default')

OpenID Connect Settings

URL to the OIDC discovery document

SAML Settings

URL to the SAML metadata XML

User Attribute Mapping

The attribute to use as the username

The attribute to use as the email address

The attribute to use as the display name

The attribute that contains user groups

Cancel if !isNew { }
} func getValue(provider *db.AuthProvider, field string) string { if provider == nil { return "" } switch field { case "name": return provider.Name case "provider_url": return provider.ProviderURL case "client_id": return provider.ClientID case "redirect_url": return provider.RedirectURL case "scopes": return provider.Scopes case "icon_url": return provider.IconURL default: return "" } } func getRedirectURL(provider *db.AuthProvider) string { if provider == nil || provider.RedirectURL == "" { return fmt.Sprintf("https://%s/auth/callback", "your-app-domain.com") } return provider.RedirectURL } func getConfigValue(provider *db.AuthProvider, key string) string { if provider == nil || provider.Config == "" { return "" } var config map[string]interface{} if err := json.Unmarshal([]byte(provider.Config), &config); err != nil { return "" } if value, ok := config[key]; ok { if strValue, ok := value.(string); ok { return strValue } } return "" } func getAttributeValue(provider *db.AuthProvider, key string) string { if provider == nil || provider.AttributeMapping == "" { return "" } var mapping map[string]string if err := json.Unmarshal([]byte(provider.AttributeMapping), &mapping); err != nil { return "" } if value, ok := mapping[key]; ok { return value } return "" }