diff --git a/app/Http/Controllers/API/UserController.php b/app/Http/Controllers/API/UserController.php index 0048c72..29bed74 100644 --- a/app/Http/Controllers/API/UserController.php +++ b/app/Http/Controllers/API/UserController.php @@ -69,7 +69,7 @@ class UserController extends BaseController $_SESSION["token"] = $token->token; } - return new AccessToken($token); + return $response->withData(new AccessToken($token)); } public function me(Response $response) { diff --git a/public/docs/api.yml b/public/docs/api.yml new file mode 100644 index 0000000..7ad2eda --- /dev/null +++ b/public/docs/api.yml @@ -0,0 +1,349 @@ +swagger: "2.0" +info: + description: "API Dokumentation for keksAccount oAuth Service." + version: "1.0.0" + title: "KeksAccount" + contact: + email: "admin@keks.cloud" + license: + name: "Apache 2.0" + url: "http://www.apache.org/licenses/LICENSE-2.0.html" +host: "api.account.keks.cloud" +basePath: "/api/v1" +tags: + - name: "account" + description: "The User-Account" + - name: "user" + description: "Register and Login to an Account" +schemes: + - "https" +paths: + /user/register: + post: + tags: + - "user" + summary: "Register a new Account" + description: "Possible if registration is enabled or the request contains a valide invide" + produces: + - "application/json" + consumes: + - "multipart/form-data" + - "application/json" + parameters: + - in: formData + name: username + description: "Username for the new User" + required: true + type: string + - in: formData + name: password + description: "Password for the new User" + required: true + type: string + - in: formData + name: mail + description: "A valide E-Mail adress for the User" + required: true + type: string + - in: formData + name: invite + description: "If the user have an invite code to create the account" + required: false + type: string + - in: formData + name: g-recaptcha-response + description: "If google recaptcha is enabled for account creation this parameter is requierd" + required: false + type: string + responses: + 200: + description: "User Account crated" + schema: + type: "object" + properties: + data: + $ref: '#/definitions/User' + success: + type: "boolean" + example: true + msg: + type: "string" + example: "" + 400: + description: "Register disabled, you may can register with an valide invite code" + schema: + type: "object" + properties: + success: + type: "boolean" + example: false + msg: + type: "string" + example: "Registration disabled" + 422: + description: "Some of the data ar missing or invalide, see data in the response object for details" + schema: + type: "object" + properties: + data: + type: "object" + properties: + username: + type: array + items: + type: string + example: "The username field is required." + password: + type: array + items: + type: string + example: "The password field is required." + mail: + type: array + items: + type: string + example: "The mail field is required." + success: + type: "boolean" + example: false + msg: + type: "string" + example: "The given data was invalid." + /user/login: + post: + tags: + - "user" + summary: "Login to an Account with Username/Passwort" + description: "Login with Passwort for the keksAccount GUI, dont use this in your Application." + produces: + - "application/json" + consumes: + - "multipart/form-data" + - "application/json" + parameters: + - in: formData + name: username + description: "Username" + required: true + type: string + - in: formData + name: password + description: "Password" + required: true + type: string + responses: + 200: + description: "Login succesfull" + schema: + type: "object" + properties: + data: + type: "object" + properties: + access_token: + type: "string" + description: "Access Token for the user" + token_type: + type: "string" + description: "Typ of the Token" + example: "" + success: + type: "boolean" + example: true + msg: + type: "string" + example: "" + 400: + description: "Register disabled, you may can register with an valide invite code" + schema: + type: "object" + properties: + success: + type: "boolean" + example: false + msg: + type: "string" + example: "Registration disabled" + 422: + description: "Some of the data ar missing or invalide, see data in the response object for details" + schema: + type: "object" + properties: + data: + type: "object" + properties: + username: + type: array + items: + type: string + example: "The username field is required." + password: + type: array + items: + type: string + example: "The password field is required." + success: + type: "boolean" + example: false + msg: + type: "string" + example: "The given data was invalid." + /user/captcha: + get: + tags: + - "user" + summary: "Return the Captcha Key and Settings" + description: "Return the Google Recaptcha Key and the list of actions the captcha is enabled/required for" + produces: + - "application/json" + responses: + 200: + description: "Captcha Informations" + schema: + type: "object" + properties: + data: + type: "object" + properties: + key: + type: "string" + description: "Pubplic Recaptcha code" + login: + type: "boolean" + description: "Show captcha if the User want to loging" + example: true + register: + type: "boolean" + description: "Show captcha if the User want to register" + example: true + success: + type: "boolean" + example: true + msg: + type: "string" + example: "" + + /user/invites: + get: + tags: + - "user" + summary: "Return information about an invite code" + description: "" + produces: + - "application/json" + parameters: + - in: query + name: code + description: "The invite code" + required: true + type: string + responses: + 200: + description: "Captcha Informations" + schema: + type: "object" + properties: + data: + type: "object" + properties: + usable: + type: "boolean" + example: true + description: "If the value is true the invite code is valide and can be used to register a new account" + username: + type: "string" + description: "If a username is set the user have to use this username for the registration" + example: "" + success: + type: "boolean" + example: true + msg: + type: "string" + example: "" + 404: + description: "Invite code not found" + schema: + type: "object" + properties: + success: + type: "boolean" + example: false + msg: + type: "string" + example: "Resource not Found" + /user/me: + get: + tags: + - "user" + summary: "Return information about the current User" + description: "" + produces: + - "application/json" + responses: + 200: + description: "Found user and return informations" + schema: + type: "object" + properties: + data: + $ref: '#/definitions/User' + success: + type: "boolean" + example: true + msg: + type: "string" + example: "" + 401: + description: "Not logged in" + schema: + type: "object" + properties: + success: + type: "boolean" + example: false + msg: + type: "string" + example: "You need to login" + +definitions: + User: + type: "object" + properties: + id: + type: "integer" + format: "int64" + example: 18 + username: + type: "string" + example: "testaccount" + created_at: + type: "string" + format: "DateTime" + example: "2019-07-17T13:37:40.000000Z" + updated_at: + type: "string" + format: "DateTime" + example: "2019-07-17T13:37:40.000000Z" + primaryMail: + type: "string" + format: "mail" + example: "mail@example.com" + status: + type: "string" + description: "Account Status" + example: "active" + enum: + - "active" + inviteCode: + type: "string" + example: "sdjfios" + description: "Invite Code used to register this Account" + developer: + type: "boolean" + example: false + description: "If the user is a developer Account (Can create new Apps)" + admin: + type: "boolean" + example: false + description: "If the user is a admin Account" + \ No newline at end of file diff --git a/public/docs/favicon-16x16.png b/public/docs/favicon-16x16.png new file mode 100755 index 0000000..0f7e13b Binary files /dev/null and b/public/docs/favicon-16x16.png differ diff --git a/public/docs/favicon-32x32.png b/public/docs/favicon-32x32.png new file mode 100755 index 0000000..b0a3352 Binary files /dev/null and b/public/docs/favicon-32x32.png differ diff --git a/public/docs/index.html b/public/docs/index.html new file mode 100755 index 0000000..6e2976e --- /dev/null +++ b/public/docs/index.html @@ -0,0 +1,96 @@ + + + +
+ +>>u&mn;if(_!==h>>>u&mn)break;_&&(l+=(1<i&&(c=c.removeBefore(r,u,a-l)),c&&h
a&&(a=c.size),o(u)||(c=c.map(function(e){return K(e)})),i.push(c)}return a>e.size&&(e=e.setSize(a)),Ie(e,t,i)}function $e(e){return es)return k();var e=i.next();return r||t===bn?e:t===_n?w(t,u-1,void 0,e):w(t,u-1,e.value[1],e)})},c}function dt(e,t,n){var r=Dt(e);return r.__iterateUncached=function(r,i){var o=this;if(i)return this.cacheResult().__iterate(r,i);var a=0;return e.__iterate(function(e,i,s){return t.call(n,e,i,s)&&++a&&r(e,i,o)}),a},r.__iteratorUncached=function(r,i){var o=this;if(i)return this.cacheResult().__iterator(r,i);var a=e.__iterator(xn,i),s=!0;return new x(function(){if(!s)return k();var e=a.next();if(e.done)return e;var i=e.value,u=i[0],c=i[1];return t.call(n,c,u,o)?r===xn?e:w(r,u,c,e):(s=!1,k())})},r}function mt(e,t,n,r){var i=Dt(e);return i.__iterateUncached=function(i,o){var a=this;if(o)return this.cacheResult().__iterate(i,o);var s=!0,u=0;return e.__iterate(function(e,o,c){if(!s||!(s=t.call(n,e,o,c)))return u++,i(e,r?o:u-1,a)}),u},i.__iteratorUncached=function(i,o){var a=this;if(o)return this.cacheResult().__iterator(i,o);var s=e.__iterator(xn,o),u=!0,c=0;return new x(function(){var e,o,l;do{if(e=s.next(),e.done)return r||i===bn?e:i===_n?w(i,c++,void 0,e):w(i,c++,e.value[1],e);var p=e.value;o=p[0],l=p[1],u&&(u=t.call(n,l,o,a))}while(u);return i===xn?e:w(i,o,l,e)})},i}function vt(e,t){var r=a(e),i=[e].concat(t).map(function(e){return o(e)?r&&(e=n(e)):e=r?L(e):q(Array.isArray(e)?e:[e]),e}).filter(function(e){return 0!==e.size});if(0===i.length)return e;if(1===i.length){var u=i[0];if(u===e||r&&a(u)||s(e)&&s(u))return u}var c=new I(i);return r?c=c.toKeyedSeq():s(e)||(c=c.toSetSeq()),c=c.flatten(!0),c.size=i.reduce(function(e,t){if(void 0!==e){var n=t.size;if(void 0!==n)return e+n}},0),c}function gt(e,t,n){var r=Dt(e);return r.__iterateUncached=function(r,i){function a(e,c){var l=this;e.__iterate(function(e,i){return(!t||c=Vn)return Me(e,f,c,s,d);if(l&&!d&&2===f.length&&Se(f[1^p]))return f[1^p];if(l&&d&&1===f.length&&Se(d))return d;var m=e&&e===this.ownerID,v=l?d?c:c^u:c|u,g=l?d?Ne(f,p,d,m):Be(f,p,m):Fe(f,p,d,m);return m?(this.bitmap=v,this.nodes=g,this):new de(e,v,g)},me.prototype.get=function(e,t,n,r){void 0===t&&(t=oe(n));var i=(0===e?t:t>>>e)&mn,o=this.nodes[i];return o?o.get(e+hn,t,n,r):r},me.prototype.update=function(e,t,n,r,i,o,a){void 0===n&&(n=oe(r));var s=(0===t?n:n>>>t)&mn,u=i===vn,c=this.nodes,l=c[s];if(u&&!l)return this;var p=Ee(l,e,t+hn,n,r,i,o,a);if(p===l)return this;var f=this.count;if(l){if(!p&&--f5e3)return e.textContent;return function(e){for(var n,r,i,o,a,s=e.textContent,u=0,c=s[0],l=1,p=e.innerHTML="",f=0;r=n,n=f<7&&"\\"==n?1:l;){if(l=c,c=s[++u],o=p.length>1,!l||f>8&&"\n"==l||[/\S/.test(l),1,1,!/[$\w]/.test(l),("/"==n||"\n"==n)&&o,'"'==n&&o,"'"==n&&o,s[u-4]+r+n=="--\x3e",r+n=="*/"][f])for(p&&(e.appendChild(a=t.createElement("span")).setAttribute("style",["color: #555; font-weight: bold;","","","color: #555;",""][f?f<3?2:f>6?4:f>3?3:+/^(a(bstract|lias|nd|rguments|rray|s(m|sert)?|uto)|b(ase|egin|ool(ean)?|reak|yte)|c(ase|atch|har|hecked|lass|lone|ompl|onst|ontinue)|de(bugger|cimal|clare|f(ault|er)?|init|l(egate|ete)?)|do|double|e(cho|ls?if|lse(if)?|nd|nsure|num|vent|x(cept|ec|p(licit|ort)|te(nds|nsion|rn)))|f(allthrough|alse|inal(ly)?|ixed|loat|or(each)?|riend|rom|unc(tion)?)|global|goto|guard|i(f|mp(lements|licit|ort)|n(it|clude(_once)?|line|out|stanceof|t(erface|ernal)?)?|s)|l(ambda|et|ock|ong)|m(icrolight|odule|utable)|NaN|n(amespace|ative|ext|ew|il|ot|ull)|o(bject|perator|r|ut|verride)|p(ackage|arams|rivate|rotected|rotocol|ublic)|r(aise|e(adonly|do|f|gister|peat|quire(_once)?|scue|strict|try|turn))|s(byte|ealed|elf|hort|igned|izeof|tatic|tring|truct|ubscript|uper|ynchronized|witch)|t(emplate|hen|his|hrows?|ransient|rue|ry|ype(alias|def|id|name|of))|u(n(checked|def(ined)?|ion|less|signed|til)|se|sing)|v(ar|irtual|oid|olatile)|w(char_t|hen|here|hile|ith)|xor|yield)$/.test(p):0]),a.appendChild(t.createTextNode(p))),i=f&&f<7?f:i,p="",f=11;![1,/[\/{}[(\-+*=<>:;|\\.,?!&@~]/.test(l),/[\])]/.test(l),/[$\w]/.test(l),"/"==l&&i<2&&"<"!=n,'"'==l,"'"==l,l+c+s[u+1]+s[u+2]=="\x3c!--",l+c=="/*",l+c=="//","#"==l][--f];);p+=l}}(e)}function x(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"key",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:B.default.Map();if(!B.default.Map.isMap(e)||!e.size)return B.default.List();if(Array.isArray(t)||(t=[t]),t.length<1)return e.merge(n);var r=B.default.List(),i=t[0],o=!0,a=!1,s=void 0;try{for(var u,c=(0,O.default)(e.entries());!(o=(u=c.next()).done);o=!0){var l=u.value,p=(0,D.default)(l,2),f=p[0],h=p[1],d=x(h,t.slice(1),n.set(i,f));r=B.default.List.isList(d)?r.concat(d):r.push(d)}}catch(e){a=!0,s=e}finally{try{!o&&c.return&&c.return()}finally{if(a)throw s}}return r}function w(e){return(0,U.default)((0,q.default)(e))}function k(e){return w(e.replace(/\.[^.\/]*$/,""))}function E(e){if(!B.default.OrderedMap.isOrderedMap(e))return null;if(!e.size)return null;var t=e.find(function(e,t){return t.startsWith("2")&&(0,j.default)(e.get("content")||{}).length>0}),n=e.get("default")||B.default.OrderedMap(),r=(n.get("content")||B.default.OrderedMap()).keySeq().toJS(),i=r.length?n:null;return t||i}Object.defineProperty(t,"__esModule",{value:!0}),t.escapeDeepLinkPath=t.createDeepLinkPath=t.shallowEqualKeys=t.buildFormData=t.sorters=t.btoa=t.parseSearch=t.getSampleSchema=t.validateParam=t.validateString=t.validateBoolean=t.validateFile=t.validateInteger=t.validateNumber=t.propChecker=t.errorLog=t.memoize=t.isImmutable=void 0;var S=n(42),C=r(S),A=n(16),D=r(A),M=n(89),O=r(M),T=n(34),P=r(T),I=n(52),j=r(I),R=n(43),N=r(R);t.isJSONObject=i,t.objectify=o,t.arrayify=a,t.fromJSOrdered=s,t.bindToState=u,t.normalizeArray=c,t.isFn=l,t.isObject=p,t.isFunc=f,t.isArray=h,t.objMap=d,t.objReduce=m,t.systemThunkMiddleware=v,t.defaultStatusCode=g,t.getList=y,t.formatXml=_,t.highlight=b,t.mapToList=x,t.pascalCase=w,t.pascalCaseFilename=k,t.getAcceptControllingResponse=E;var F=n(8),B=r(F),L=n(881),q=r(L),z=n(405),U=r(z),W=n(403),V=r(W),K=n(397),H=r(K),J=n(896),G=r(J),X=n(112),Y=r(X),$=n(166),Z=n(51),Q=r(Z),ee=n(645),te=r(ee),ne="default",re=t.isImmutable=function(e){return B.default.Iterable.isIterable(e)},ie=(t.memoize=V.default,t.errorLog=function(e){return function(){return function(t){return function(n){try{t(n)}catch(t){e().errActions.newThrownErr(t,n)}}}}},t.propChecker=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[];return(0,j.default)(e).length!==(0,j.default)(t).length||((0,G.default)(e,function(e,n){if(r.includes(n))return!1;var i=t[n];return B.default.Iterable.isIterable(e)?!B.default.is(e,i):("object"!==(void 0===e?"undefined":(0,N.default)(e))||"object"!==(void 0===i?"undefined":(0,N.default)(i)))&&e!==i})||n.some(function(n){return!(0,Y.default)(e[n],t[n])}))},t.validateNumber=function(e){if(!/^-?\d+(\.?\d+)?$/.test(e))return"Value must be a number"}),oe=t.validateInteger=function(e){if(!/^-?\d+$/.test(e))return"Value must be an integer"},ae=t.validateFile=function(e){if(e&&!(e instanceof Q.default.File))return"Value must be a file"},se=t.validateBoolean=function(e){if("true"!==e&&"false"!==e&&!0!==e&&!1!==e)return"Value must be a boolean"},ue=t.validateString=function(e){if(e&&"string"!=typeof e)return"Value must be a string"},ce=(t.validateParam=function(e,t){var n=[],r=t&&"body"===e.get("in")?e.get("value_xml"):e.get("value"),i=e.get("required"),o=e.get("type");if(o&&(i||r)){var a="string"===o&&r&&!ue(r),s="array"===o&&Array.isArray(r)&&r.length,u="array"===o&&B.default.List.isList(r)&&r.count(),c="file"===o&&r instanceof Q.default.File,l="boolean"===o&&!se(r),p="number"===o&&!ie(r),f="integer"===o&&!oe(r);if(i&&!(a||s||u||c||l||p||f))return n.push("Required field is not provided"),n;if("string"===o){var h=ue(r);if(!h)return n;n.push(h)}else if("boolean"===o){var d=se(r);if(!d)return n;n.push(d)}else if("number"===o){var m=ie(r);if(!m)return n;n.push(m)}else if("integer"===o){var v=oe(r);if(!v)return n;n.push(v)}else if("array"===o){var g=void 0;if(!r.count())return n;g=e.getIn(["items","type"]),r.forEach(function(e,t){var r=void 0;"number"===g?r=ie(e):"integer"===g?r=oe(e):"string"===g&&(r=ue(e)),r&&n.push({index:t,error:r})})}else if("file"===o){var y=ae(r);if(!y)return n;n.push(y)}}return n},t.getSampleSchema=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(/xml/.test(t)){if(!e.xml||!e.xml.name){if(e.xml=e.xml||{},!e.$$ref)return e.type||e.items||e.properties||e.additionalProperties?'\n\x3c!-- XML example cannot be generated --\x3e':null;var r=e.$$ref.match(/\S*\/(\S+)$/);e.xml.name=r[1]}return(0,$.memoizedCreateXMLExample)(e,n)}return(0,C.default)((0,$.memoizedSampleFromSchema)(e,n),null,2)},t.parseSearch=function(){var e={},t=window.location.search;if(""!=t){var n=t.substr(1).split("&");for(var r in n)r=n[r].split("="),e[decodeURIComponent(r[0])]=decodeURIComponent(r[1])}return e},t.btoa=function(t){var n=void 0;return n=t instanceof e?t:new e(t.toString(),"utf-8"),n.toString("base64")},t.sorters={operationsSorter:{alpha:function(e,t){return e.get("path").localeCompare(t.get("path"))},method:function(e,t){return e.get("method").localeCompare(t.get("method"))}},tagsSorter:{alpha:function(e,t){return e.localeCompare(t)}}},t.buildFormData=function(e){var t=[];for(var n in e){var r=e[n];void 0!==r&&""!==r&&t.push([n,"=",encodeURIComponent(r).replace(/%20/g,"+")].join(""))}return t.join("&")},t.shallowEqualKeys=function(e,t,n){return!!(0,H.default)(n,function(n){return(0,Y.default)(e[n],t[n])})},t.createDeepLinkPath=function(e){return"string"==typeof e||e instanceof String?e.trim().replace(/\s/g,"_"):""});t.escapeDeepLinkPath=function(e){return(0,te.default)(ce(e))}}).call(t,n(45).Buffer)},function(e,t,n){"use strict";function r(e){if(null===e||void 0===e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}/*
+object-assign
+(c) Sindre Sorhus
+@license MIT
+*/
+var i=Object.getOwnPropertySymbols,o=Object.prototype.hasOwnProperty,a=Object.prototype.propertyIsEnumerable;e.exports=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(t).map(function(e){return t[e]}).join(""))return!1;var r={};return"abcdefghijklmnopqrst".split("").forEach(function(e){r[e]=e}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},r)).join("")}catch(e){return!1}}()?Object.assign:function(e,t){for(var n,s,u=r(e),c=1;c5?c-5:0),p=5;p5?c-5:0),p=5;ps&&(n=s-u),c=n;c>=0;c--){for(var p=!0,f=0;fi&&(r=i):r=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");r>o/2&&(r=o/2);for(var a=0;a