aboutsummaryrefslogtreecommitdiffstats
path: root/services/auth/source/saml/name_id_format.go
blob: 1ddf0477297bd82b5fef074fbdce882427b7fca6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT

package saml

type NameIDFormat int

const (
	SAML11Email NameIDFormat = iota + 1
	SAML11Persistent
	SAML11Unspecified
	SAML20Email
	SAML20Persistent
	SAML20Transient
	SAML20Unspecified
)

const DefaultNameIDFormat NameIDFormat = SAML20Persistent

var NameIDFormatNames = map[NameIDFormat]string{
	SAML11Email:       "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress",
	SAML11Persistent:  "urn:oasis:names:tc:SAML:1.1:nameid-format:persistent",
	SAML11Unspecified: "urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified",
	SAML20Email:       "urn:oasis:names:tc:SAML:2.0:nameid-format:emailAddress",
	SAML20Persistent:  "urn:oasis:names:tc:SAML:2.0:nameid-format:persistent",
	SAML20Transient:   "urn:oasis:names:tc:SAML:2.0:nameid-format:transient",
	SAML20Unspecified: "urn:oasis:names:tc:SAML:2.0:nameid-format:unspecified",
}

// String returns the name of the NameIDFormat
func (n NameIDFormat) String() string {
	return NameIDFormatNames[n]
}

// Int returns the int value of the NameIDFormat
func (n NameIDFormat) Int() int {
	return int(n)
}