(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-2d0e9558"],{"8ca8":function(e,t,a){"use strict";a.r(t);var s=function(){var e=this,t=e.$createElement;e._self._c;return e._m(0)},i=[function(){var e=this,t=e.$createElement,a=e._self._c||t;return a("div",{staticClass:"aliases"},[a("h3",{staticClass:"mt-4"},[e._v("Anatomy of a request URL")]),e._v(" https:// domain / APIv / "),a("code",[e._v("token")]),e._v(" / "),a("code",[e._v("alias")]),e._v(" / path-to-image ? "),a("code",[e._v("transformations")]),a("ul",{staticClass:"list-group mt-2"},[a("li",{staticClass:"list-group-item"},[e._v(" domain "),a("i",{staticClass:"fa fa-chevron-right"}),e._v(" Custom domains will be supported in a future release. ")]),a("li",{staticClass:"list-group-item"},[e._v(" APIv "),a("i",{staticClass:"fa fa-chevron-right"}),e._v(" v2 ")]),a("li",{staticClass:"list-group-item"},[e._v(" token "),a("i",{staticClass:"fa fa-chevron-right"}),e._v(" Your account token ")]),a("li",{staticClass:"list-group-item"},[e._v(" alias "),a("i",{staticClass:"fa fa-chevron-right"}),e._v(' Analogous to a "folder" in ixmage terms ')]),a("li",{staticClass:"list-group-item"},[e._v(" path-to-image "),a("i",{staticClass:"fa fa-chevron-right"}),e._v(" Complete the path to your image based on the "),a("code",[e._v("alias")])]),a("li",{staticClass:"list-group-item"},[e._v(" transformations "),a("i",{staticClass:"fa fa-chevron-right"}),e._v(" Changes to apply to your image ")])]),a("h1",{staticClass:"jumptarget",attrs:{id:"overview"}},[e._v("Aliases")]),a("p",[e._v(" An alias is an association of a string token with a url containing a domain. "),a("br"),e._v("Example: "),a("code",[e._v(" bucket1 ")]),e._v(" => "),a("code",[e._v(" https://s3-us-west-2.amazonaws.com/my.bucket.name ")])]),a("div",{staticClass:"alert alert-info"},[a("i",{staticClass:"fa fa-info-circle mr-2"}),e._v(" "),a("code",[e._v(" bucket1 ")]),e._v(" is alias to "),a("code",[e._v(" https://s3-us-west-2.amazonaws.com/my.bucket.name ")])]),a("p",[e._v(" This helps in creating an image url like "),a("code",[e._v("/v2/token/alias/path-to-image")])]),a("p",[e._v(" Let's say there is an image "),a("code",[e._v("image1.png")]),e._v(" in that bucket, instead of "),a("br"),a("code",[e._v("/v2/token/https://s3-us-west-2.amazonaws.com/my.bucket.name/image1.png")]),a("br"),e._v("we could do "),a("br"),a("code",[e._v("/v2/token/bucket1/image1.png")])]),a("p",[e._v(" The alias will be resolved, effectively hiding the real source of the image. ")]),a("div",{staticClass:"alert alert-warning"},[a("i",{staticClass:"fa fa-exclamation-circle mr-2"}),e._v(" Depending on the source of the images, case sensitivity may need to be honored. For example, AWS S3 buckets do require case-sensitivity where "),a("code",[e._v("image.png")]),e._v(" and "),a("code",[e._v("Image.PNG")]),e._v(" are different urls. ")]),a("h3",{staticClass:"mt-4"},[e._v("Other Alias functionalities")]),a("p",[e._v(" Aliases also serve as methods to configure "),a("code",[e._v("Access")]),e._v(" and enable "),a("code",[e._v("Watermarking")])]),a("h4",{staticClass:"jumptarget",attrs:{id:"access"}},[e._v("Access")]),a("p",[e._v(" By default, an alias permits requests from anyone. This can be controlled by allowing "),a("code",[e._v("referers")]),e._v(" into a whitelist. ")]),a("p",[e._v(" So when a referer list is empty, this means it's open for all. Adding referers turns it into a whitelist where only allowed domains have access. ")]),a("p",{staticClass:"alert alert-info"},[e._v(" A "),a("b",[e._v("referer")]),e._v(" is the requesting party identified by their "),a("code",[e._v("Request Header Referer")]),e._v(". The protocol is not needed. ")]),a("p",[e._v(" Example: "),a("code",[e._v("//example.com")]),a("br"),e._v("Adding this referer will allow requests from any page within the "),a("code",[e._v("//example.com")]),e._v(" domain. ")]),a("h4",{staticClass:"jumptarget",attrs:{id:"watermarks"}},[e._v("Watermarking")]),a("p",[e._v(" Watermarks only work when overlaying a "),a("code",[e._v("png")]),e._v(" image as the watermark. The watermarked image can be of any format. ")]),a("p",[e._v(" There are two main watermaking setups: "),a("br"),a("code",[e._v("Tiled")]),e._v(" and "),a("code",[e._v("non-Tiled")])]),a("h5",{staticClass:"mt-4"},[e._v("Tiled")]),a("p",[e._v(" A tiled watermark will take a "),a("code",[e._v("png")]),e._v(" and paint it on top of your image as many times as it can, one after the other, going across and going down. ")]),a("img",{staticClass:"img-demo",attrs:{src:"https://cdn.ixmage.com/v2/grappler/wmark-tile/photos/2017.01.00/IMG_4205.JPG?w=320&h=180&bgc=_abd&v=20210204b"}}),a("h5",{staticClass:"mt-4"},[e._v("No Tiles")]),a("p",[e._v(" For a no-tile watermark, you can specify its "),a("code",[e._v("position")])]),a("img",{staticClass:"img-demo",attrs:{src:"https://cdn.ixmage.com/v2/grappler/wmark-notile/photos/2017.01.00/IMG_4205.JPG?w=320&h=180&bgc=_abd&v=20210204b"}}),a("br"),e._v(" The list of valid positions is "),a("pre",[e._v("northwest north northeast\nwest center east\nsouthwest south southeast")]),a("h4",{staticClass:"jumptarget",attrs:{id:"wateraccess"}},[e._v("Watermarking + Access")]),a("p",[e._v(" Combining the two mechanics above, we can setup a group of images to be watermarked when used in certain domains, and have no watermark when used in others. ")]),a("pre",[e._v("aliases: [\n {\n name: 'watermarked',\n url: 'https://my-image-repo/photos',\n watermark: {\n img: 'https://my-image-repo/watermarks/photo-watermark.png',\n tiled: true\n }\n },\n {\n name: 'nowatermark',\n url: 'https://my-image-repo/photos',\n referers: [\n '//my-domain.com', '//my-other-domain.com'\n ]\n }\n]")]),a("p",[e._v(" Both aliases pointing to the same source but named and setup differently. The first one watermarks any requests, and the second one only responds to the two mentioned referers. ")]),a("p",[e._v(" When you request "),a("code",[e._v("/v2//watermarked/photo001.jpg")]),e._v(" it will be watermarked. There is no referer list on this alias, so anyone can use it. ")]),a("p",[e._v(" When you request "),a("code",[e._v("/v2//nowatermark/photo001.jpg")]),e._v(" it will not be watermarked, and it will only work on webpages from the domains in the "),a("code",[e._v("referers")]),e._v(" list. ")]),a("h4",{staticClass:"jumptarget",attrs:{id:"locking"}},[e._v("Locking up an Alias")]),a("p",[e._v(" Every alias has a "),a("code",[e._v("locked")]),e._v(" flag which when turned on, will require a "),a("code",[e._v("key")]),e._v(" parameter to open it. ")]),a("div",{staticClass:"alert alert-info"},[e._v(" The key value is a SHA1 version of your "),a("code",[e._v("token")]),e._v(" + "),a("code",[e._v("querystring")]),e._v(" + "),a("code",[e._v("secret")])]),a("p",[e._v(" The "),a("code",[e._v("querystring")]),e._v(" part should not contain the "),a("code",[e._v("&key")]),e._v(" parameter. "),a("br")]),a("div",{staticClass:"alert alert-warning"},[a("i",{staticClass:"fa fa-warning"}),e._v(" This technique is meant to be used server-side, because the "),a("code",[e._v("secret")]),e._v(" should not be exposed publicly. ")]),a("p",[e._v(" There is a key that will unlock any of your aliases, by using your account secret. "),a("br"),e._v("You can generate secrets per alias, so you do not have to hand out the master key, but instead you can hand out keys to a specific alias. You can also revoke these keys at anytime. ")]),a("pre",[a("span",{staticStyle:{color:"#080"}},[e._v("// given a querystring of 'hei=240&wid=400', sort its characters like ")]),e._v("\nquerystring = querystring.split('').sort().join('')\n"),a("span",{staticStyle:{color:"#080"}},[e._v("// this produces '&000244==dehiiw'")]),e._v("\nkey = sha1('my-account-token' + '&000244==dehiiw' + 'my-secret')\nurl = '/v2/my-account-token/_alias/image.jpg?wid=400&hei=240&key=' + key\n")]),a("div",{staticClass:"alert alert-info"},[e._v(" Provide good examples in different server-side languages "),a("br"),e._v("Node.js | PHP | C# | Python | Ruby | JAVA | ... ")]),a("p",[e._v(" If the key is not valid, a 403 error is returned. "),a("br"),e._v("If anyone tries to change the operations, like change the "),a("code",[e._v("wid")]),e._v(" to 500, then the key will not be valid anymore. ")])])}],o={name:"Aliases",components:{}},r=o,n=a("2877"),l=Object(n["a"])(r,s,i,!1,null,null,null);t["default"]=l.exports}}]); //# sourceMappingURL=chunk-2d0e9558.c2371625.js.map