MCPcopy Create free account
hub / github.com/crewjam/saml / currentAccount

Function currentAccount

example/service.go:63–74  ·  view source on GitHub ↗

currentAccount returns the SAML NameID of the signed-in user, which identifies the owner of a link. It is taken from the session samlsp established, never from a request header a client could set itself.

(r *http.Request)

Source from the content-addressed store, hash-verified

61// identifies the owner of a link. It is taken from the session samlsp
62// established, never from a request header a client could set itself.
63func currentAccount(r *http.Request) (string, bool) {
64 switch session := samlsp.SessionFromContext(r.Context()).(type) {
65 case samlsp.JWTSessionClaims:
66 // The default session codec stores the NameID value as the subject.
67 return session.Subject, session.Subject != ""
68 case samlsp.SessionWithSAMLNameID:
69 nameID, ok := session.GetSAMLNameID()
70 return nameID.Value, ok && nameID.Value != ""
71 default:
72 return "", false
73 }
74}
75
76// newShortLink returns a random, URL-safe short link name.
77func newShortLink() (string, error) {

Callers 2

CreateLinkFunction · 0.85
ListLinksFunction · 0.85

Calls 2

SessionFromContextFunction · 0.92
GetSAMLNameIDMethod · 0.65

Tested by

no test coverage detected