Nerzal / gocloak

golang keycloak client
Apache License 2.0
1.01k stars 275 forks source link

adding an option to add logout redirect URLs #442

Open justmike1 opened 1 year ago

justmike1 commented 1 year ago

Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

I want to add to my client a logout redirect URL, like I do with

        clientClient := gocloak.Client{
            PublicClient:              gocloak.BoolP(true),
            RootURL:                   gocloak.StringP(clientServerURL),
            AdminURL:                  gocloak.StringP(clientServerURL),
            RedirectURIs:              &[]string{clientServerURL + "/*"},
            WebOrigins:                &[]string{clientServerURL},
            ClientID:                  gocloak.StringP(clientClientName),
            ImplicitFlowEnabled:       gocloak.BoolP(true),
            DirectAccessGrantsEnabled: gocloak.BoolP(true),
        }

Describe the solution you'd like A clear and concise description of what you want to happen.

something like:

        clientClient := gocloak.Client{
                ....
            RedirectURIs:              &[]string{clientServerURL + "/*"},
            LogoutRedirectURIs:  &[]string{clientServerURL + "/*"},
            ....
        }

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

None.

Additional context Add any other context or screenshots about the feature request here.

this box in client section: image

vlaborie commented 4 months ago

Hi,

You can define logout redirect URIs with Client.Attributes, eg:

clientID := "exampleclient"
c := &gocloak.Client{
        ClientID: &clientID,
}
logoutURIs := []string{"/logout", "/example"}
attr := make(map[string]string)
attr["post.logout.redirect.uris"] = strings.Join(logoutURIs, "##")
c.Attributes = &attr

ps: multiple URIs need to be join with ## (double hashtag)

vlaborie commented 4 months ago

It's seems you can configure every attributes configurable by Keycloak admin UI like this, and even add custom one.