feat: Configureer auth Swagger
This commit is contained in:
parent
e139f59afa
commit
855620cb67
5 changed files with 125 additions and 5 deletions
|
@ -9,14 +9,17 @@ router.get('/config', (req, res) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
router.get('/testAuthenticatedOnly', authenticatedOnly, (req, res) => {
|
router.get('/testAuthenticatedOnly', authenticatedOnly, (req, res) => {
|
||||||
|
/* #swagger.security = [{ "student": [ ] }, { "teacher": [ ] }] */
|
||||||
res.json({message: "If you see this, you should be authenticated!"});
|
res.json({message: "If you see this, you should be authenticated!"});
|
||||||
});
|
});
|
||||||
|
|
||||||
router.get('/testStudentsOnly', studentsOnly, (req, res) => {
|
router.get('/testStudentsOnly', studentsOnly, (req, res) => {
|
||||||
|
/* #swagger.security = [{ "student": [ ] }] */
|
||||||
res.json({message: "If you see this, you should be a student!"});
|
res.json({message: "If you see this, you should be a student!"});
|
||||||
});
|
});
|
||||||
|
|
||||||
router.get('/testTeachersOnly', teachersOnly, (req, res) => {
|
router.get('/testTeachersOnly', teachersOnly, (req, res) => {
|
||||||
|
/* #swagger.security = [{ "teacher": [ ] }] */
|
||||||
res.json({message: "If you see this, you should be a teacher!"});
|
res.json({message: "If you see this, you should be a teacher!"});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,37 @@ const doc = {
|
||||||
{
|
{
|
||||||
url: 'https://sel2-1.ugent.be/api'
|
url: 'https://sel2-1.ugent.be/api'
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
components: {
|
||||||
|
securitySchemes: {
|
||||||
|
student: {
|
||||||
|
type: 'oauth2',
|
||||||
|
flows: {
|
||||||
|
implicit: {
|
||||||
|
authorizationUrl: 'http://localhost:7080/realms/student/protocol/openid-connect/auth',
|
||||||
|
scopes: {
|
||||||
|
openid: 'openid',
|
||||||
|
profile: 'profile',
|
||||||
|
email: 'email'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
teacher: {
|
||||||
|
type: 'oauth2',
|
||||||
|
flows: {
|
||||||
|
implicit: {
|
||||||
|
authorizationUrl: 'http://localhost:7080/realms/teacher/protocol/openid-connect/auth',
|
||||||
|
scopes: {
|
||||||
|
openid: 'openid',
|
||||||
|
profile: 'profile',
|
||||||
|
email: 'email'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const outputFile = './swagger.json';
|
const outputFile = './swagger.json';
|
||||||
|
|
|
@ -520,10 +520,10 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"/login/": {
|
"/auth/config": {
|
||||||
"get": {
|
"get": {
|
||||||
"tags": [
|
"tags": [
|
||||||
"Login"
|
"Auth"
|
||||||
],
|
],
|
||||||
"description": "",
|
"description": "",
|
||||||
"responses": {
|
"responses": {
|
||||||
|
@ -533,6 +533,63 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/auth/testAuthenticatedOnly": {
|
||||||
|
"get": {
|
||||||
|
"tags": [
|
||||||
|
"Auth"
|
||||||
|
],
|
||||||
|
"description": "",
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"student": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"teacher": []
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/auth/testStudentsOnly": {
|
||||||
|
"get": {
|
||||||
|
"tags": [
|
||||||
|
"Auth"
|
||||||
|
],
|
||||||
|
"description": "",
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"student": []
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/auth/testTeachersOnly": {
|
||||||
|
"get": {
|
||||||
|
"tags": [
|
||||||
|
"Auth"
|
||||||
|
],
|
||||||
|
"description": "",
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"teacher": []
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
"/theme/": {
|
"/theme/": {
|
||||||
"get": {
|
"get": {
|
||||||
"tags": [
|
"tags": [
|
||||||
|
@ -708,5 +765,35 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"components": {
|
||||||
|
"securitySchemes": {
|
||||||
|
"student": {
|
||||||
|
"type": "oauth2",
|
||||||
|
"flows": {
|
||||||
|
"implicit": {
|
||||||
|
"authorizationUrl": "http://localhost:7080/realms/student/protocol/openid-connect/auth",
|
||||||
|
"scopes": {
|
||||||
|
"openid": "openid",
|
||||||
|
"profile": "profile",
|
||||||
|
"email": "email"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"teacher": {
|
||||||
|
"type": "oauth2",
|
||||||
|
"flows": {
|
||||||
|
"implicit": {
|
||||||
|
"authorizationUrl": "http://localhost:7080/realms/teacher/protocol/openid-connect/auth",
|
||||||
|
"scopes": {
|
||||||
|
"openid": "openid",
|
||||||
|
"profile": "profile",
|
||||||
|
"email": "email"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -551,7 +551,7 @@
|
||||||
"enabled" : true,
|
"enabled" : true,
|
||||||
"alwaysDisplayInConsole" : false,
|
"alwaysDisplayInConsole" : false,
|
||||||
"clientAuthenticatorType" : "client-jwt",
|
"clientAuthenticatorType" : "client-jwt",
|
||||||
"redirectUris" : [ "urn:ietf:wg:oauth:2.0:oob", "http://localhost:5173/*", "http://localhost:5173" ],
|
"redirectUris" : [ "urn:ietf:wg:oauth:2.0:oob", "http://localhost:5173/*", "http://localhost:5173", "http://localhost:3000/api-docs/oauth2-redirect.html" ],
|
||||||
"webOrigins" : [ "+" ],
|
"webOrigins" : [ "+" ],
|
||||||
"notBefore" : 0,
|
"notBefore" : 0,
|
||||||
"bearerOnly" : false,
|
"bearerOnly" : false,
|
||||||
|
|
|
@ -551,7 +551,7 @@
|
||||||
"enabled" : true,
|
"enabled" : true,
|
||||||
"alwaysDisplayInConsole" : false,
|
"alwaysDisplayInConsole" : false,
|
||||||
"clientAuthenticatorType" : "client-secret",
|
"clientAuthenticatorType" : "client-secret",
|
||||||
"redirectUris" : [ "urn:ietf:wg:oauth:2.0:oob", "http://localhost:5173/*", "http://localhost:5173" ],
|
"redirectUris" : [ "urn:ietf:wg:oauth:2.0:oob", "http://localhost:5173/*", "http://localhost:5173", "http://localhost:3000/api-docs/oauth2-redirect.html" ],
|
||||||
"webOrigins" : [ "+" ],
|
"webOrigins" : [ "+" ],
|
||||||
"notBefore" : 0,
|
"notBefore" : 0,
|
||||||
"bearerOnly" : false,
|
"bearerOnly" : false,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue