auth

Paddy 2014-08-16 Parent:fc5df8e68c7b Child:9fc5fd8196b4

21:51700827b6ee Go to Latest

auth/client.go

Redirect after login. After a successful login, redirect based on a query parameter. Only allow redirections to the domain listed in the config and its subdomains. If no redirect is specified, redirect to the root of the domain listed in the config.

History
1 package auth
3 import (
4 "secondbit.org/uuid"
5 )
7 // Client information
8 type Client struct {
9 ID uuid.ID
10 Secret string
11 RedirectURI string
12 OwnerID uuid.ID
13 Name string
14 Logo string
15 }
17 func GetClient(id uuid.ID, ctx Context) (Client, error) {
18 return ctx.Clients.GetClient(id)
19 }
21 func createClient(name, logo, redirectURI string, owner uuid.ID, ctx Context) (Client, error) {
22 return ctx.Clients.CreateClient(name, logo, redirectURI, owner)
23 }
25 func updateClient(client *Client, name, logo, redirectURI *string, ctx Context) error {
26 if client == nil {
27 return NilClientError
28 }
29 err := ctx.Clients.UpdateClient(client.ID, name, logo, redirectURI)
30 if err != nil {
31 return err
32 }
33 if name != nil {
34 client.Name = *name
35 }
36 if logo != nil {
37 client.Logo = *logo
38 }
39 if redirectURI != nil {
40 client.RedirectURI = *redirectURI
41 }
42 return nil
43 }
45 func removeClient(id uuid.ID, ctx Context) error {
46 return ctx.Clients.RemoveClient(id)
47 }
49 func listClients(id uuid.ID, page, num int, ctx Context) ([]Client, error) {
50 return ctx.Clients.ListClients(id, page, num)
51 }