mirror of
https://github.com/documize/community.git
synced 2025-07-28 01:29:43 +02:00
Get firstname and lastname from CAS attributes
This commit is contained in:
parent
15e687841f
commit
fbb73560c0
2 changed files with 30 additions and 1 deletions
21
domain/auth/cas/README.md
Normal file
21
domain/auth/cas/README.md
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
# Authenticating with Aperao CAS
|
||||||
|
|
||||||
|
## Introduction
|
||||||
|
|
||||||
|
Documize can delegate user authentication to aperao CAS integration.
|
||||||
|
|
||||||
|
This document assumes that the Documize administrator has installed and is familiar with CAS server.
|
||||||
|
|
||||||
|
https://www.apereo.org/projects/cas
|
||||||
|
|
||||||
|
Documize is tested against the CAS version 5.3.x.
|
||||||
|
|
||||||
|
## Configuring Documize
|
||||||
|
|
||||||
|
CAS authentication is configured and enabled from Settings.
|
||||||
|
|
||||||
|
Type in the CAS Server URL, Redirect URL.
|
||||||
|
|
||||||
|
* **CAS Server URL**: The CAS host address, eg: `https://cas.example.com`
|
||||||
|
* **Redirect URL**: The CAS authorize callback URL. If your documize URL is `https://example.documize.com,` then redirect URL is `https://example.documize.com/auth/cas`.
|
||||||
|
|
|
@ -112,7 +112,15 @@ func (h *Handler) Authenticate(w http.ResponseWriter, r *http.Request) {
|
||||||
u.Admin = false
|
u.Admin = false
|
||||||
u.GlobalAdmin = false
|
u.GlobalAdmin = false
|
||||||
u.Email = userInfo.User
|
u.Email = userInfo.User
|
||||||
u.Initials = stringutil.MakeInitials(userInfo.User, "")
|
|
||||||
|
firstName := userInfo.Attributes.Get("first_name")
|
||||||
|
lastName := userInfo.Attributes.Get("last_name")
|
||||||
|
if firstName != "" || lastName != "" {
|
||||||
|
u.Initials = stringutil.MakeInitials(firstName, lastName)
|
||||||
|
}else {
|
||||||
|
u.Initials = stringutil.MakeInitials(userInfo.User, "")
|
||||||
|
}
|
||||||
|
|
||||||
u.Salt = secrets.GenerateSalt()
|
u.Salt = secrets.GenerateSalt()
|
||||||
u.Password = secrets.GeneratePassword(secrets.GenerateRandomPassword(), u.Salt)
|
u.Password = secrets.GeneratePassword(secrets.GenerateRandomPassword(), u.Salt)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue