Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cashier
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Kevin Lyda
cashier
Commits
dfae6ee4
Commit
dfae6ee4
authored
6 years ago
by
Kevin Lyda
Browse files
Options
Downloads
Patches
Plain Diff
Cleaned up and documented MSG-API usage.
parent
d6f45c49
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
server/auth/microsoft/microsoft.go
+14
-14
14 additions, 14 deletions
server/auth/microsoft/microsoft.go
with
14 additions
and
14 deletions
server/auth/microsoft/microsoft.go
+
14
−
14
View file @
dfae6ee4
...
@@ -85,9 +85,6 @@ func (c *Config) getDocument(token *oauth2.Token, pathElements ...string) map[st
...
@@ -85,9 +85,6 @@ func (c *Config) getDocument(token *oauth2.Token, pathElements ...string) map[st
// https://developer.microsoft.com/en-us/graph/docs/concepts/v1-overview
// https://developer.microsoft.com/en-us/graph/docs/concepts/v1-overview
func
(
c
*
Config
)
getMe
(
token
*
oauth2
.
Token
,
item
string
)
string
{
func
(
c
*
Config
)
getMe
(
token
*
oauth2
.
Token
,
item
string
)
string
{
document
:=
c
.
getDocument
(
token
,
"/me"
)
document
:=
c
.
getDocument
(
token
,
"/me"
)
if
len
(
document
)
==
0
{
return
""
}
if
value
,
ok
:=
document
[
item
]
.
(
string
);
ok
{
if
value
,
ok
:=
document
[
item
]
.
(
string
);
ok
{
return
value
return
value
}
}
...
@@ -97,9 +94,19 @@ func (c *Config) getMe(token *oauth2.Token, item string) string {
...
@@ -97,9 +94,19 @@ func (c *Config) getMe(token *oauth2.Token, item string) string {
// Check against verified domains from "/organization" endpoint of MSG-API.
// Check against verified domains from "/organization" endpoint of MSG-API.
func
(
c
*
Config
)
verifyTenant
(
token
*
oauth2
.
Token
)
bool
{
func
(
c
*
Config
)
verifyTenant
(
token
*
oauth2
.
Token
)
bool
{
document
:=
c
.
getDocument
(
token
,
"/organization"
)
document
:=
c
.
getDocument
(
token
,
"/organization"
)
if
len
(
document
)
==
0
{
// The domains for an organisation are in an array of structs under
return
false
// verifiedDomains, which is in a struct which is in turn an array
}
// of such structs under value in the document. Which in json looks
// like this:
// { "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#organization",
// "value": [ {
// ...
// "verifiedDomains": [ {
// ...
// "name": "M365x214355.onmicrosoft.com",
// } ]
// } ]
//}
var
value
[]
interface
{}
var
value
[]
interface
{}
var
ok
bool
var
ok
bool
if
value
,
ok
=
document
[
"value"
]
.
([]
interface
{});
!
ok
{
if
value
,
ok
=
document
[
"value"
]
.
([]
interface
{});
!
ok
{
...
@@ -121,14 +128,7 @@ func (c *Config) verifyTenant(token *oauth2.Token) bool {
...
@@ -121,14 +128,7 @@ func (c *Config) verifyTenant(token *oauth2.Token) bool {
// Check against groups from /users/{id}/memberOf endpoint of MSG-API.
// Check against groups from /users/{id}/memberOf endpoint of MSG-API.
func
(
c
*
Config
)
verifyGroups
(
token
*
oauth2
.
Token
)
bool
{
func
(
c
*
Config
)
verifyGroups
(
token
*
oauth2
.
Token
)
bool
{
id
:=
c
.
getMe
(
token
,
"id"
)
document
:=
c
.
getDocument
(
token
,
"/users/me/memberOf"
)
if
id
==
""
{
return
false
}
document
:=
c
.
getDocument
(
token
,
"/users/"
,
id
,
"/memberOf"
)
if
len
(
document
)
==
0
{
return
false
}
var
value
[]
interface
{}
var
value
[]
interface
{}
var
ok
bool
var
ok
bool
if
value
,
ok
=
document
[
"value"
]
.
([]
interface
{});
!
ok
{
if
value
,
ok
=
document
[
"value"
]
.
([]
interface
{});
!
ok
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment